Skip to content

Commit

Permalink
Merge pull request #10634 from k8s-infra-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-10632-to-release-1.7

[release-1.7] 🐛 Check that replicas pointer is not nil in machinepool controller
  • Loading branch information
k8s-ci-robot committed May 16, 2024
2 parents 37b9873 + d7a9274 commit 3e5204e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions exp/internal/controllers/machinepool_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 3e5204e

Please sign in to comment.