@@ -60,7 +60,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
6060 }
6161
6262 // Set the phase to "provisioning" if bootstrap is ready and the infrastructure isn't.
63- if mp .Status .BootstrapReady && ! mp .Status .InfrastructureReady {
63+ if mp .Status .Initialization != nil && mp . Status . Initialization . BootstrapDataSecretCreated && ! mp .Status .Initialization . InfrastructureProvisioned {
6464 mp .Status .SetTypedPhase (expv1 .MachinePoolPhaseProvisioning )
6565 }
6666
@@ -75,12 +75,12 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
7575 if mp .Status .Deprecated != nil && mp .Status .Deprecated .V1Beta1 != nil {
7676 readyReplicas = mp .Status .Deprecated .V1Beta1 .ReadyReplicas
7777 }
78- if mp .Status .InfrastructureReady && mp .Spec .Replicas != nil && * mp .Spec .Replicas == readyReplicas {
78+ if mp .Status .Initialization != nil && mp . Status . Initialization . InfrastructureProvisioned && mp .Spec .Replicas != nil && * mp .Spec .Replicas == readyReplicas {
7979 mp .Status .SetTypedPhase (expv1 .MachinePoolPhaseRunning )
8080 }
8181
8282 // Set the appropriate phase in response to the MachinePool replica count being greater than the observed infrastructure replicas.
83- if mp .Status .InfrastructureReady && mp .Spec .Replicas != nil && * mp .Spec .Replicas > readyReplicas {
83+ if mp .Status .Initialization != nil && mp . Status . Initialization . InfrastructureProvisioned && mp .Spec .Replicas != nil && * mp .Spec .Replicas > readyReplicas {
8484 // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling".
8585 if annotations .ReplicasManagedByExternalAutoscaler (mp ) {
8686 mp .Status .SetTypedPhase (expv1 .MachinePoolPhaseScaling )
@@ -91,7 +91,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
9191 }
9292
9393 // Set the appropriate phase in response to the MachinePool replica count being less than the observed infrastructure replicas.
94- if mp .Status .InfrastructureReady && mp .Spec .Replicas != nil && * mp .Spec .Replicas < readyReplicas {
94+ if mp .Status .Initialization != nil && mp . Status . Initialization . InfrastructureProvisioned && mp .Spec .Replicas != nil && * mp .Spec .Replicas < readyReplicas {
9595 // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling".
9696 if annotations .ReplicasManagedByExternalAutoscaler (mp ) {
9797 mp .Status .SetTypedPhase (expv1 .MachinePoolPhaseScaling )
@@ -231,7 +231,10 @@ func (r *MachinePoolReconciler) reconcileBootstrap(ctx context.Context, s *scope
231231
232232 if ! dataSecretCreated {
233233 log .Info ("Waiting for bootstrap provider to generate data secret and report status.ready" , bootstrapConfig .GetKind (), klog .KObj (bootstrapConfig ))
234- m .Status .BootstrapReady = dataSecretCreated
234+ if m .Status .Initialization == nil {
235+ m .Status .Initialization = & expv1.MachinePoolInitializationStatus {}
236+ }
237+ m .Status .Initialization .BootstrapDataSecretCreated = dataSecretCreated
235238 return ctrl.Result {}, nil
236239 }
237240
@@ -244,13 +247,19 @@ func (r *MachinePoolReconciler) reconcileBootstrap(ctx context.Context, s *scope
244247 }
245248
246249 m .Spec .Template .Spec .Bootstrap .DataSecretName = secretName
247- m .Status .BootstrapReady = true
250+ if m .Status .Initialization == nil {
251+ m .Status .Initialization = & expv1.MachinePoolInitializationStatus {}
252+ }
253+ m .Status .Initialization .BootstrapDataSecretCreated = true
248254 return ctrl.Result {}, nil
249255 }
250256
251257 // If dataSecretName is set without a ConfigRef, this means the user brought their own bootstrap data.
252258 if m .Spec .Template .Spec .Bootstrap .DataSecretName != nil {
253- m .Status .BootstrapReady = true
259+ if m .Status .Initialization == nil {
260+ m .Status .Initialization = & expv1.MachinePoolInitializationStatus {}
261+ }
262+ m .Status .Initialization .BootstrapDataSecretCreated = true
254263 v1beta1conditions .MarkTrue (m , clusterv1 .BootstrapReadyV1Beta1Condition )
255264 return ctrl.Result {}, nil
256265 }
@@ -269,7 +278,7 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s *
269278 if err != nil {
270279 if apierrors .IsNotFound (errors .Cause (err )) {
271280 log .Error (err , "infrastructure reference could not be found" )
272- if mp .Status .InfrastructureReady {
281+ if mp .Status .Initialization != nil && mp . Status . Initialization . InfrastructureProvisioned {
273282 // Infra object went missing after the machine pool was up and running
274283 log .Error (err , "infrastructure reference has been deleted after being ready, setting failure state" )
275284 if mp .Status .Deprecated == nil {
@@ -297,7 +306,10 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s *
297306 return ctrl.Result {}, err
298307 }
299308
300- mp .Status .InfrastructureReady = ready
309+ if mp .Status .Initialization == nil {
310+ mp .Status .Initialization = & expv1.MachinePoolInitializationStatus {}
311+ }
312+ mp .Status .Initialization .InfrastructureProvisioned = ready
301313
302314 // Report a summary of current status of the infrastructure object defined for this machine pool.
303315 v1beta1conditions .SetMirror (mp , clusterv1 .InfrastructureReadyV1Beta1Condition ,
@@ -320,7 +332,7 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s *
320332 return ctrl.Result {}, kerrors .NewAggregate ([]error {errors .Wrapf (err , "failed to reconcile Machines for MachinePool %s" , klog .KObj (mp )), errors .Wrapf (getNodeRefsErr , "failed to get nodeRefs for MachinePool %s" , klog .KObj (mp ))})
321333 }
322334
323- if ! mp .Status .InfrastructureReady {
335+ if mp . Status . Initialization == nil && ! mp .Status .Initialization . InfrastructureProvisioned {
324336 log .Info ("Infrastructure provider is not yet ready" , infraConfig .GetKind (), klog .KObj (infraConfig ))
325337 return ctrl.Result {}, nil
326338 }
0 commit comments