Skip to content

Commit

Permalink
inmemorymachine: set v1beta2 Paused condition
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Oct 15, 2024
1 parent 4b2c30b commit 9b80dea
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"sigs.k8s.io/cluster-api/util/finalizers"
clog "sigs.k8s.io/cluster-api/util/log"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/cluster-api/util/paused"
"sigs.k8s.io/cluster-api/util/predicates"
"sigs.k8s.io/cluster-api/util/secret"
)
Expand Down Expand Up @@ -123,6 +124,10 @@ func (r *InMemoryMachineReconciler) Reconcile(ctx context.Context, req ctrl.Requ
log = log.WithValues("Cluster", klog.KObj(cluster))
ctx = ctrl.LoggerInto(ctx, log)

if isPaused, conditionChanged, err := paused.EnsurePausedCondition(ctx, r.Client, cluster, inMemoryMachine); err != nil || isPaused || conditionChanged {
return ctrl.Result{}, err
}

// Return early if the object or Cluster is paused.
if annotations.IsPaused(cluster, inMemoryMachine) {
log.Info("Reconciliation is paused for this object")
Expand Down Expand Up @@ -1146,7 +1151,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct
err = ctrl.NewControllerManagedBy(mgr).
For(&infrav1.InMemoryMachine{}).
WithOptions(options).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
Watches(
&clusterv1.Machine{},
handler.EnqueueRequestsFromMapFunc(util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("InMemoryMachine"))),
Expand All @@ -1159,7 +1164,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct
&clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(clusterToInMemoryMachines),
builder.WithPredicates(
predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetScheme(), predicateLog),
predicates.ClusterInfrastructureReady(mgr.GetScheme(), predicateLog),
),
).Complete(r)
if err != nil {
Expand Down

0 comments on commit 9b80dea

Please sign in to comment.