Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset ProgressDeadline on retry #282

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions rollout/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,47 @@ func TestCanaryRolloutUpdatePauseConditionWhilePaused(t *testing.T) {
assert.Equal(t, calculatePatch(r2, expectedPatch), patch)
}

func TestCanaryRolloutResetProgressDeadlineOnRetry(t *testing.T) {
f := newFixture(t)
defer f.Close()

steps := []v1alpha1.CanaryStep{
{
Pause: &v1alpha1.RolloutPause{},
},
}
r1 := newCanaryRollout("foo", 10, nil, steps, pointer.Int32Ptr(0), intstr.FromInt(1), intstr.FromInt(0))
r2 := bumpVersion(r1)

progressingCondition, _ := newProgressingCondition(conditions.RolloutAbortedReason, r2)
conditions.SetRolloutCondition(&r2.Status, progressingCondition)

rs1 := newReplicaSetWithStatus(r1, 10, 10)
rs2 := newReplicaSetWithStatus(r2, 0, 0)

f.kubeobjects = append(f.kubeobjects, rs1, rs2)
rs1PodHash := rs1.Labels[v1alpha1.DefaultRolloutUniqueLabelKey]
f.replicaSetLister = append(f.replicaSetLister, rs1, rs2)

r2 = updateCanaryRolloutStatus(r2, rs1PodHash, 10, 0, 10, false)
r2.Status.Abort = false
f.rolloutLister = append(f.rolloutLister, r2)
f.objects = append(f.objects, r2)

addPausedConditionPatch := f.expectPatchRolloutAction(r2)
f.expectPatchRolloutAction(r2)
f.run(getKey(r2, t))

patch := f.getPatchedRollout(addPausedConditionPatch)
_, retryCondition := newProgressingCondition(conditions.RolloutRetryReason, r2)
expectedPatch := fmt.Sprintf(`{
"status": {
"conditions": [%s]
}
}`, retryCondition)
assert.Equal(t, calculatePatch(r2, expectedPatch), patch)
}

func TestCanaryRolloutIncrementStepAfterUnPaused(t *testing.T) {
f := newFixture(t)
defer f.Close()
Expand Down
4 changes: 4 additions & 0 deletions rollout/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func newProgressingCondition(reason string, resourceObj runtime.Object) (v1alpha
msg = fmt.Sprintf(conditions.RolloutAnalysisRunFailedMessage, arName, resource.Name)
status = corev1.ConditionFalse
}
if reason == conditions.RolloutRetryReason {
msg = conditions.RolloutRetryMessage
status = corev1.ConditionUnknown
}
case *corev1.Service:
if reason == conditions.ServiceNotFoundReason {
msg = fmt.Sprintf(conditions.ServiceNotFoundMessage, resource.Name)
Expand Down
5 changes: 5 additions & 0 deletions rollout/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ func (c *RolloutController) checkPausedConditions(r *v1alpha1.Rollout) error {
updatedConditon = conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionUnknown, conditions.ResumedRolloutReason, conditions.ResumeRolloutMessage)
}

abortCondExists := cond != nil && cond.Reason == conditions.RolloutAbortedReason
if !r.Status.Abort && abortCondExists {
updatedConditon = conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionUnknown, conditions.RolloutRetryReason, conditions.RolloutRetryMessage)
}

if updatedConditon == nil {
return nil
}
Expand Down
9 changes: 8 additions & 1 deletion utils/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ const (
RolloutAbortedReason = "RolloutAborted"
// RolloutAbortedMessage indicates that the rollout was aborted
RolloutAbortedMessage = "Rollout is aborted"
// RolloutRetryReason indicates that the rollout is retrying after being aborted
RolloutRetryReason = "RolloutRetry"
// RolloutRetryMessage indicates that the rollout is retrying after being aborted
RolloutRetryMessage = "Retrying Rollout after abort"

// NewRSAvailableReason is added in a rollout when its newest replica set is made available
// ie. the number of new pods that have passed readiness checks and run for at least minReadySeconds
Expand Down Expand Up @@ -402,7 +406,10 @@ func RolloutTimedOut(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatu
// If it's already set with a TimedOutReason reason, we have already timed out, no need to check
// again.
condition := GetRolloutCondition(*newStatus, v1alpha1.RolloutProgressing)
if condition == nil {
// When a rollout is retried, the controller should not evaluate for a timeout based on the
// aborted condition because the abort could have happened a while back and the rollout should
// not enter degraded as a result of that
if condition == nil || condition.Reason == RolloutAbortedReason {
return false
}

Expand Down