@@ -87,14 +87,14 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
87
87
handler .EnqueueRequestsFromMapFunc (r .MachineSetToDeployments ),
88
88
).
89
89
WithOptions (options ).
90
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (ctrl .LoggerFrom (ctx ), r .WatchFilterValue )).
90
+ WithEventFilter (predicates .ResourceHasFilterLabel (ctrl .LoggerFrom (ctx ), r .WatchFilterValue )).
91
91
Watches (
92
92
& clusterv1.Cluster {},
93
93
handler .EnqueueRequestsFromMapFunc (clusterToMachineDeployments ),
94
94
builder .WithPredicates (
95
95
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
96
96
predicates .All (ctrl .LoggerFrom (ctx ),
97
- predicates .ClusterUnpaused (ctrl .LoggerFrom (ctx )),
97
+ predicates .ClusterCreateUpdateEvent (ctrl .LoggerFrom (ctx )),
98
98
),
99
99
),
100
100
).Complete (r )
@@ -130,12 +130,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
130
130
return ctrl.Result {}, err
131
131
}
132
132
133
- // Return early if the object or Cluster is paused.
134
- if annotations .IsPaused (cluster , deployment ) {
135
- log .Info ("Reconciliation is paused for this object" )
136
- return ctrl.Result {}, nil
137
- }
138
-
139
133
// Initialize the patch helper
140
134
patchHelper , err := patch .NewHelper (deployment , r .Client )
141
135
if err != nil {
@@ -154,6 +148,29 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
154
148
}
155
149
}()
156
150
151
+ // Return early and set the paused condition to True if the object or Cluster
152
+ // is paused.
153
+ if annotations .IsPaused (cluster , deployment ) {
154
+ log .Info ("Reconciliation is paused for this object" )
155
+
156
+ newPausedCondition := & clusterv1.Condition {
157
+ Type : clusterv1 .PausedCondition ,
158
+ Status : corev1 .ConditionTrue ,
159
+ Severity : clusterv1 .ConditionSeverityInfo ,
160
+ }
161
+
162
+ if cluster .Spec .Paused {
163
+ newPausedCondition .Reason = clusterv1 .ClusterPausedReason
164
+ } else {
165
+ newPausedCondition .Reason = clusterv1 .AnnotationPausedReason
166
+ }
167
+
168
+ conditions .Set (deployment , newPausedCondition )
169
+ return ctrl.Result {}, nil
170
+ }
171
+
172
+ conditions .MarkFalseWithNegativePolarity (deployment , clusterv1 .PausedCondition )
173
+
157
174
// Ignore deleted MachineDeployments, this can happen when foregroundDeletion
158
175
// is enabled
159
176
if ! deployment .DeletionTimestamp .IsZero () {
@@ -261,6 +278,15 @@ func (r *Reconciler) reconcile(ctx context.Context, cluster *clusterv1.Cluster,
261
278
}
262
279
263
280
if md .Spec .Paused {
281
+ log .Info ("This machine deployment is paused. Sync and status updates will still be reconciled" )
282
+ newPausedCondition := & clusterv1.Condition {
283
+ Type : clusterv1 .PausedCondition ,
284
+ Status : corev1 .ConditionTrue ,
285
+ Severity : clusterv1 .ConditionSeverityInfo ,
286
+ Reason : clusterv1 .MachineDeploymentPausedReason ,
287
+ }
288
+
289
+ conditions .Set (md , newPausedCondition )
264
290
return r .sync (ctx , md , msList )
265
291
}
266
292
0 commit comments