@@ -25,6 +25,7 @@ import (
25
25
apierrors "k8s.io/apimachinery/pkg/api/errors"
26
26
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
27
27
"sigs.k8s.io/cluster-api/util"
28
+ "sigs.k8s.io/cluster-api/util/annotations"
28
29
"sigs.k8s.io/cluster-api/util/collections"
29
30
"sigs.k8s.io/cluster-api/util/patch"
30
31
"sigs.k8s.io/cluster-api/util/predicates"
@@ -94,10 +95,6 @@ func (r *TinkerbellMachineReconciler) Reconcile(ctx context.Context, req ctrl.Re
94
95
95
96
scope .patchHelper = patchHelper
96
97
97
- if scope .MachineScheduledForDeletion () {
98
- return ctrl.Result {}, scope .DeleteMachineWithDependencies ()
99
- }
100
-
101
98
// We must be bound to a CAPI Machine object before we can continue.
102
99
machine , err := scope .getReadyMachine ()
103
100
if err != nil {
@@ -108,6 +105,26 @@ func (r *TinkerbellMachineReconciler) Reconcile(ctx context.Context, req ctrl.Re
108
105
return ctrl.Result {}, nil
109
106
}
110
107
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 {}, fmt .Errorf ("getting owner cluster: %w" , err )
113
+ }
114
+ }
115
+
116
+ // TODO(enhancement): Currently using simple annotation-based pause checking. Need to implement
117
+ // proper pause handling using paused.EnsurePausedCondition() as per:
118
+ // https://cluster-api.sigs.k8s.io/developer/providers/contracts/infra-cluster#infracluster-pausing
119
+ if annotations .IsPaused (cluster , scope .tinkerbellMachine ) {
120
+ log .Info ("TinkerbellMachine is paused, skipping reconciliation" )
121
+ return ctrl.Result {}, nil
122
+ }
123
+
124
+ if scope .MachineScheduledForDeletion () {
125
+ return ctrl.Result {}, scope .DeleteMachineWithDependencies ()
126
+ }
127
+
111
128
// We need a bootstrap cloud config secret to bootstrap the node so we can't proceed without it.
112
129
// Typically, this is something akin to cloud-init user-data.
113
130
bootstrapCloudConfig , err := scope .getReadyBootstrapCloudConfig (machine )
0 commit comments