Skip to content

Commit 53d5c2e

Browse files
authored
Merge pull request #10632 from Fedosin/machinepool_check_replicas_nil
🐛 Check that replicas pointer is not nil in machinepool controller
2 parents 06fc6e9 + d164abc commit 53d5c2e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

exp/internal/controllers/machinepool_controller_phases.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
6868
}
6969

7070
// Set the phase to "running" if the number of ready replicas is equal to desired replicas.
71-
if mp.Status.InfrastructureReady && *mp.Spec.Replicas == mp.Status.ReadyReplicas {
71+
if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas == mp.Status.ReadyReplicas {
7272
mp.Status.SetTypedPhase(expv1.MachinePoolPhaseRunning)
7373
}
7474

7575
// Set the appropriate phase in response to the MachinePool replica count being greater than the observed infrastructure replicas.
76-
if mp.Status.InfrastructureReady && *mp.Spec.Replicas > mp.Status.ReadyReplicas {
76+
if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas > mp.Status.ReadyReplicas {
7777
// If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling".
7878
if annotations.ReplicasManagedByExternalAutoscaler(mp) {
7979
mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling)
@@ -84,7 +84,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
8484
}
8585

8686
// Set the appropriate phase in response to the MachinePool replica count being less than the observed infrastructure replicas.
87-
if mp.Status.InfrastructureReady && *mp.Spec.Replicas < mp.Status.ReadyReplicas {
87+
if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas < mp.Status.ReadyReplicas {
8888
// If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling".
8989
if annotations.ReplicasManagedByExternalAutoscaler(mp) {
9090
mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling)

0 commit comments

Comments
 (0)