@@ -162,15 +162,6 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(req ctrl.Request) (res ctrl.Re
162
162
}
163
163
}
164
164
165
- // Always update the readyCondition.
166
- conditions .SetSummary (kcp ,
167
- conditions .WithConditions (
168
- controlplanev1 .MachinesReadyCondition ,
169
- controlplanev1 .AvailableCondition ,
170
- controlplanev1 .CertificatesAvailableCondition ,
171
- ),
172
- )
173
-
174
165
// Always attempt to update status.
175
166
if err := r .updateStatus (ctx , kcp , cluster ); err != nil {
176
167
var connFailure * internal.RemoteClusterConnectionError
@@ -182,6 +173,17 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(req ctrl.Request) (res ctrl.Re
182
173
}
183
174
}
184
175
176
+ // Always update the readyCondition.
177
+ conditions .SetSummary (kcp ,
178
+ conditions .WithConditions (
179
+ controlplanev1 .MachinesSpecUpToDateCondition ,
180
+ controlplanev1 .ResizedCondition ,
181
+ controlplanev1 .MachinesReadyCondition ,
182
+ controlplanev1 .AvailableCondition ,
183
+ controlplanev1 .CertificatesAvailableCondition ,
184
+ ),
185
+ )
186
+
185
187
// Always attempt to Patch the KubeadmControlPlane object and status after each reconciliation.
186
188
if err := patchHelper .Patch (ctx , kcp ); err != nil {
187
189
logger .Error (err , "Failed to patch KubeadmControlPlane" )
@@ -269,14 +271,25 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
269
271
controlPlane := internal .NewControlPlane (cluster , kcp , ownedMachines )
270
272
271
273
// Aggregate the operational state of all the machines; while aggregating we are adding the
272
- // source ref to the aggregate reason (reason@machine/name) so the problem can be easily tracked down to its source.
274
+ // source ref (reason@machine/name) so the problem can be easily tracked down to its source machine .
273
275
conditions .SetAggregate (controlPlane .KCP , controlplanev1 .MachinesReadyCondition , ownedMachines .ConditionGetters (), conditions .AddSourceRef ())
274
276
275
- requireUpgrade := controlPlane .MachinesNeedingUpgrade ()
276
- // Upgrade takes precedence over other operations
277
- if len (requireUpgrade ) > 0 {
278
- logger .Info ("Upgrading Control Plane" )
277
+ // Control plane machines rollout due to configuration changes (e.g. upgrades) takes precedence over other operations.
278
+ needRollout := controlPlane .MachinesNeedingRollout ()
279
+ switch {
280
+ case len (needRollout ) > 0 :
281
+ logger .Info ("Rolling out Control Plane machines" )
282
+ // NOTE: we are using Status.UpdatedReplicas from the previous reconciliation only to provide a meaningful message
283
+ // and this does not influence any reconciliation logic.
284
+ conditions .MarkFalse (controlPlane .KCP , controlplanev1 .MachinesSpecUpToDateCondition , controlplanev1 .RollingUpdateInProgressReason , clusterv1 .ConditionSeverityWarning , "Rolling %d replicas with outdated spec (%d replicas up to date)" , len (needRollout ), kcp .Status .UpdatedReplicas )
279
285
return r .upgradeControlPlane (ctx , cluster , kcp , controlPlane )
286
+ default :
287
+ // make sure last upgrade operation is marked as completed.
288
+ // NOTE: we are checking the condition already exists in order to avoid to set this condition at the first
289
+ // reconciliation/before a rolling upgrade actually starts.
290
+ if conditions .Has (controlPlane .KCP , controlplanev1 .MachinesSpecUpToDateCondition ) {
291
+ conditions .MarkTrue (controlPlane .KCP , controlplanev1 .MachinesSpecUpToDateCondition )
292
+ }
280
293
}
281
294
282
295
// If we've made it this far, we can assume that all ownedMachines are up to date
0 commit comments