Skip to content

Commit

Permalink
dockermachine: 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 b227dbf commit a39ea9a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"sigs.k8s.io/cluster-api/util/labels"
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"
)

Expand Down Expand Up @@ -119,6 +120,10 @@ func (r *DockerMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, nil
}

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

log = log.WithValues("Cluster", klog.KObj(cluster))
ctx = ctrl.LoggerInto(ctx, log)

Expand Down Expand Up @@ -487,7 +492,7 @@ func (r *DockerMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl
err = ctrl.NewControllerManagedBy(mgr).
For(&infrav1.DockerMachine{}).
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("DockerMachine"))),
Expand All @@ -500,7 +505,7 @@ func (r *DockerMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl
&clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(clusterToDockerMachines),
builder.WithPredicates(
predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetScheme(), predicateLog),
predicates.ClusterInfrastructureReady(mgr.GetScheme(), predicateLog),
),
).Complete(r)
if err != nil {
Expand Down

0 comments on commit a39ea9a

Please sign in to comment.