Skip to content

Commit

Permalink
Merge pull request #11 from Fedosin/check_replicas_nil
Browse files Browse the repository at this point in the history
🐛 Check that replicas pointer is not nil in reconcilePhases
  • Loading branch information
tasdikrahman authored Mar 14, 2023
2 parents 6c95c83 + 525cdc3 commit c5a8d85
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 @@ -63,12 +63,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 @@ -79,7 +79,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 c5a8d85

Please sign in to comment.