diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index 1c7a9bb32cfb..a82eaf753640 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -68,12 +68,12 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the phase to "running" if the number of ready replicas is equal to desired replicas. - if mp.Status.InfrastructureReady && *mp.Spec.Replicas == mp.Status.ReadyReplicas { + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas == mp.Status.ReadyReplicas { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseRunning) } // Set the appropriate phase in response to the MachinePool replica count being greater than the observed infrastructure replicas. - if mp.Status.InfrastructureReady && *mp.Spec.Replicas > mp.Status.ReadyReplicas { + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas > mp.Status.ReadyReplicas { // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling". if annotations.ReplicasManagedByExternalAutoscaler(mp) { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling) @@ -84,7 +84,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the appropriate phase in response to the MachinePool replica count being less than the observed infrastructure replicas. - if mp.Status.InfrastructureReady && *mp.Spec.Replicas < mp.Status.ReadyReplicas { + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas < mp.Status.ReadyReplicas { // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling". if annotations.ReplicasManagedByExternalAutoscaler(mp) { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling)