Skip to content

Commit

Permalink
revert paused changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Oct 15, 2024
1 parent 8af22aa commit 7edfa73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 78 deletions.
32 changes: 15 additions & 17 deletions internal/controllers/machineset/machineset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import (
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/collections"
"sigs.k8s.io/cluster-api/util/conditions"
v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/cluster-api/util/finalizers"
"sigs.k8s.io/cluster-api/util/labels/format"
Expand Down Expand Up @@ -124,12 +123,14 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
handler.EnqueueRequestsFromMapFunc(r.MachineToMachineSets),
).
WithOptions(options).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
Watches(
&clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(clusterToMachineSets),
builder.WithPredicates(
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
predicates.All(mgr.GetScheme(), predicateLog,
predicates.ClusterUnpaused(mgr.GetScheme(), predicateLog),
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
),
),
Expand Down Expand Up @@ -177,6 +178,12 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retres ct
return ctrl.Result{}, err
}

// Return early if the object or Cluster is paused.
if annotations.IsPaused(cluster, machineSet) {
log.Info("Reconciliation is paused for this object")
return ctrl.Result{}, nil
}

s := &scope{
cluster: cluster,
machineSet: machineSet,
Expand All @@ -189,18 +196,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retres ct
}

defer func() {
isPaused := v1beta2conditions.SetPausedCondition(s.cluster, s.machineSet)
if !isPaused {
r.reconcileStatus(ctx, s)
r.reconcileStatus(ctx, s)

if err := r.reconcileV1Beta1Status(ctx, s); err != nil {
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrapf(err, "failed to update v1beta1 status")})
}
if err := r.reconcileV1Beta1Status(ctx, s); err != nil {
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrapf(err, "failed to update v1beta1 status")})
}

// Adjust requeue for scaleups
if s.machineSet.DeletionTimestamp.IsZero() && reterr == nil {
retres = util.LowestNonZeroResult(retres, requeueAfterWaitingForNodes(s))
}
// Adjust requeue for scaleups
if s.machineSet.DeletionTimestamp.IsZero() && reterr == nil {
retres = util.LowestNonZeroResult(retres, requeueAfterWaitingForNodes(s))
}

// Always attempt to patch the object and status after each reconciliation.
Expand All @@ -209,12 +213,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retres ct
}
}()

// Return early if the object or Cluster is paused.
if annotations.IsPaused(cluster, machineSet) {
log.Info("Reconciliation is paused for this object")
return ctrl.Result{}, nil
}

alwaysReconcile := []machineSetReconcileFunc{
wrapErrMachineSetReconcileFunc(r.reconcileInfrastructure, "failed to reconcile infrastructure"),
wrapErrMachineSetReconcileFunc(r.reconcileBootstrapConfig, "failed to reconcile bootstrapConfig"),
Expand Down
1 change: 0 additions & 1 deletion internal/controllers/machineset/machineset_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func setMachinesUpToDateCondition(machineSet *clusterv1.MachineSet, machines []*
Message: "something TODO on MachinesUpToDate",
})
}

}

func setDeletingCondition(ms *clusterv1.MachineSet) {
Expand Down
60 changes: 0 additions & 60 deletions util/conditions/v1beta2/paused.go

This file was deleted.

0 comments on commit 7edfa73

Please sign in to comment.