@@ -25,6 +25,7 @@ import (
2525 apierrors "k8s.io/apimachinery/pkg/api/errors"
2626 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2727 "sigs.k8s.io/cluster-api/util"
28+ "sigs.k8s.io/cluster-api/util/annotations"
2829 "sigs.k8s.io/cluster-api/util/collections"
2930 "sigs.k8s.io/cluster-api/util/patch"
3031 "sigs.k8s.io/cluster-api/util/predicates"
@@ -94,10 +95,6 @@ func (r *TinkerbellMachineReconciler) Reconcile(ctx context.Context, req ctrl.Re
9495
9596 scope .patchHelper = patchHelper
9697
97- if scope .MachineScheduledForDeletion () {
98- return ctrl.Result {}, scope .DeleteMachineWithDependencies ()
99- }
100-
10198 // We must be bound to a CAPI Machine object before we can continue.
10299 machine , err := scope .getReadyMachine ()
103100 if err != nil {
@@ -108,6 +105,27 @@ func (r *TinkerbellMachineReconciler) Reconcile(ctx context.Context, req ctrl.Re
108105 return ctrl.Result {}, nil
109106 }
110107
108+ // Fetch the capi cluster owning the machine and check if the cluster is paused
109+ cluster , err := util .GetClusterFromMetadata (ctx , scope .client , machine .ObjectMeta )
110+ if err != nil {
111+ if ! apierrors .IsNotFound (err ) {
112+ // return ctrl.Result{Requeue: }
113+ return ctrl.Result {}, fmt .Errorf ("getting owner cluster: %w" , err )
114+ }
115+ }
116+
117+ // TODO(enhancement): Currently using simple annotation-based pause checking. Need to implement
118+ // proper pause handling using paused.EnsurePausedCondition() as per:
119+ // https://cluster-api.sigs.k8s.io/developer/providers/contracts/infra-cluster#infracluster-pausing
120+ if annotations .IsPaused (cluster , scope .tinkerbellMachine ) {
121+ log .Info ("TinkerbellMachine is paused, skipping reconciliation" )
122+ return ctrl.Result {}, nil
123+ }
124+
125+ if scope .MachineScheduledForDeletion () {
126+ return ctrl.Result {}, scope .DeleteMachineWithDependencies ()
127+ }
128+
111129 // We need a bootstrap cloud config secret to bootstrap the node so we can't proceed without it.
112130 // Typically, this is something akin to cloud-init user-data.
113131 bootstrapCloudConfig , err := scope .getReadyBootstrapCloudConfig (machine )
0 commit comments