Skip to content

Commit

Permalink
fix: nil pointer dereference when reconciling paused blue-green rollo…
Browse files Browse the repository at this point in the history
…ut (#1378)

Signed-off-by: Jesse Suen <[email protected]>
  • Loading branch information
jessesuen committed Jul 29, 2021
1 parent 8b53b2c commit 4622ae4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions rollout/bluegreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,24 @@ func (c *rolloutContext) reconcileBlueGreenPause(activeSvc, previewSvc *corev1.S
return
}
pauseCond := getPauseCondition(c.rollout, v1alpha1.PauseReasonBlueGreenPause)
if pauseCond == nil && !c.rollout.Status.ControllerPause {
if pauseCond == nil {
c.log.Info("pausing")
}
c.pauseContext.AddPauseCondition(v1alpha1.PauseReasonBlueGreenPause)
return
}

if !c.pauseContext.CompletedBlueGreenPause() {
c.log.Info("pause incomplete")
if c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds > 0 {
c.checkEnqueueRolloutDuringWait(pauseCond.StartTime, c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds)
if pauseCond != nil {
// We are currently paused. Check if we completed our pause duration
if !c.pauseContext.CompletedBlueGreenPause() {
c.log.Info("pause incomplete")
if c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds > 0 {
c.checkEnqueueRolloutDuringWait(pauseCond.StartTime, c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds)
}
} else {
c.log.Infof("pause completed")
c.pauseContext.RemovePauseCondition(v1alpha1.PauseReasonBlueGreenPause)
}
} else {
c.log.Infof("pause completed")
c.pauseContext.RemovePauseCondition(v1alpha1.PauseReasonBlueGreenPause)
// no pause condition exists. If Status.ControllerPause is true, the user manually resumed
// the rollout. e.g. `kubectl argo rollouts promote ROLLOUT`
if !c.rollout.Status.ControllerPause {
c.log.Info("pausing")
c.pauseContext.AddPauseCondition(v1alpha1.PauseReasonBlueGreenPause)
}
}
}

Expand Down

0 comments on commit 4622ae4

Please sign in to comment.