diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index 93878e189135..5ecc6ca9bcc9 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -69,12 +69,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) @@ -85,7 +85,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)