Skip to content

Commit

Permalink
fix: deprecate skip-current-step command
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrongali committed May 10, 2021
1 parent 32d37d8 commit c5d2150
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
30 changes: 20 additions & 10 deletions pkg/kubectl-argo-rollouts/cmd/promote/promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ const (
%[1]s promote guestbook
# Fully promote a rollout to desired version, skipping analysis, pauses, and steps
%[1]s promote guestbook --full
# Skip currently running canary step of a rollout
%[1]s promote guestbook --skip-current-step`
%[1]s promote guestbook --full`

promoteUsage = `Promote a rollout
Expand Down Expand Up @@ -81,6 +78,8 @@ func NewCmdPromote(o *options.ArgoRolloutsOptions) *cobra.Command {
}
cmd.Flags().BoolVarP(&skipCurrentStep, "skip-current-step", "c", false, "Skip currently running canary step")
cmd.Flags().BoolVarP(&skipAllSteps, "skip-all-steps", "a", false, "Skip remaining steps")
cmd.Flags().MarkDeprecated("skip-current-step", "use without the flag instead ex: promote ROLLOUT_NAME")
cmd.Flags().MarkShorthandDeprecated("c", "use without the flag instead ex: promote ROLLOUT_NAME")
cmd.Flags().MarkDeprecated("skip-all-steps", "use --full instead")
cmd.Flags().MarkShorthandDeprecated("a", "use --full instead")
cmd.Flags().BoolVar(&full, "full", false, "Perform a full promotion, skipping analysis, pauses, and steps")
Expand Down Expand Up @@ -150,13 +149,24 @@ func getPatches(rollout *v1alpha1.Rollout, skipCurrentStep, skipAllStep, full bo
statusPatch = []byte(promoteFullPatch)
}
default:
if rollout.Spec.Paused {
specPatch = []byte(unpausePatch)
}
if len(rollout.Status.PauseConditions) > 0 {
statusPatch = []byte(clearPauseConditionsPatch)
if rollout.Spec.Strategy.BlueGreen != nil || rollout.Spec.Paused || len(rollout.Status.PauseConditions) > 0 {
if rollout.Spec.Paused {
specPatch = []byte(unpausePatch)
}
if len(rollout.Status.PauseConditions) > 0 {
statusPatch = []byte(clearPauseConditionsPatch)
}
unifiedPatch = []byte(unpauseAndClearPauseConditionsPatch)
} else {
_, index := replicasetutil.GetCurrentCanaryStep(rollout)
// At this point, the controller knows that the rollout is a canary with steps and GetCurrentCanaryStep returns 0 if
// the index is not set in the rollout
if *index < int32(len(rollout.Spec.Strategy.Canary.Steps)) {
*index++
}
statusPatch = []byte(fmt.Sprintf(setCurrentStepIndex, *index))
unifiedPatch = statusPatch
}
unifiedPatch = []byte(unpauseAndClearPauseConditionsPatch)
}
return specPatch, statusPatch, unifiedPatch
}
4 changes: 2 additions & 2 deletions pkg/kubectl-argo-rollouts/cmd/promote/promote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestPromoteCmdSuccesFirstStep(t *testing.T) {

cmd := NewCmdPromote(o)
cmd.PersistentPreRunE = o.PersistentPreRunE
cmd.SetArgs([]string{"guestbook", "-c"})
cmd.SetArgs([]string{"guestbook"})

err := cmd.Execute()
assert.Nil(t, err)
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestPromoteCmdSuccessDoNotGoPastLastStep(t *testing.T) {

cmd := NewCmdPromote(o)
cmd.PersistentPreRunE = o.PersistentPreRunE
cmd.SetArgs([]string{"guestbook", "-c"})
cmd.SetArgs([]string{"guestbook"})

err := cmd.Execute()
assert.Nil(t, err)
Expand Down
8 changes: 4 additions & 4 deletions rollout/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ func (pCtx *pauseContext) CompletedCanaryPauseStep(pause v1alpha1.RolloutPause)
rollout := pCtx.rollout
pauseCondition := getPauseCondition(rollout, v1alpha1.PauseReasonCanaryPauseStep)

if pause.Duration != nil {
if rollout.Status.ControllerPause && pauseCondition == nil {
pCtx.log.Info("Rollout has been unpaused")
return true
} else if pause.Duration != nil {
now := metav1.Now()
if pauseCondition != nil {
expiredTime := pauseCondition.StartTime.Add(time.Duration(pause.DurationSeconds()) * time.Second)
Expand All @@ -194,9 +197,6 @@ func (pCtx *pauseContext) CompletedCanaryPauseStep(pause v1alpha1.RolloutPause)
return true
}
}
} else if rollout.Status.ControllerPause && pauseCondition == nil {
pCtx.log.Info("Rollout has been unpaused")
return true
}
return false
}
Expand Down

0 comments on commit c5d2150

Please sign in to comment.