diff --git a/rollout/sync.go b/rollout/sync.go index dd9a8e94ca..4759f490a4 100644 --- a/rollout/sync.go +++ b/rollout/sync.go @@ -678,6 +678,7 @@ func (c *rolloutContext) calculateRolloutConditions(newStatus v1alpha1.RolloutSt } if conditions.RolloutCompleted(c.rollout, &newStatus) { + // The event gets triggered in function promoteStable updateCompletedCond := conditions.NewRolloutCondition(v1alpha1.RolloutCompleted, corev1.ConditionTrue, conditions.RolloutCompletedReason, conditions.RolloutCompletedReason) conditions.SetRolloutCondition(&newStatus, *updateCompletedCond) @@ -686,7 +687,7 @@ func (c *rolloutContext) calculateRolloutConditions(newStatus v1alpha1.RolloutSt conditions.RolloutCompletedReason, conditions.RolloutCompletedReason) if conditions.SetRolloutCondition(&newStatus, *updateCompletedCond) { revision, _ := replicasetutil.Revision(c.rollout) - c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: "RolloutNotCompleted"}, + c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: conditions.RolloutNotCompletedReason}, conditions.RolloutNotCompletedMessage, revision+1, newStatus.CurrentPodHash) } } @@ -946,16 +947,6 @@ func (c *rolloutContext) promoteStable(newStatus *v1alpha1.RolloutStatus, reason revision, _ := replicasetutil.Revision(c.rollout) c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: conditions.RolloutCompletedReason}, conditions.RolloutCompletedMessage, revision, newStatus.CurrentPodHash, reason) - - //if conditions.RolloutCompleted(c.rollout, newStatus) { - // updateCompletedCond := conditions.NewRolloutCondition(v1alpha1.RolloutCompleted, corev1.ConditionTrue, - // conditions.RolloutCompletedReason, conditions.RolloutCompletedReason) - // if conditions.SetRolloutCondition(newStatus, *updateCompletedCond) { - // revision, _ := replicasetutil.Revision(c.rollout) - // c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: conditions.RolloutCompletedReason}, - // conditions.RolloutCompletedMessage, revision, newStatus.CurrentPodHash, reason) - // } - //} } return nil } diff --git a/utils/conditions/conditions.go b/utils/conditions/conditions.go index 4c6d8ad91f..66275ff48b 100644 --- a/utils/conditions/conditions.go +++ b/utils/conditions/conditions.go @@ -68,6 +68,8 @@ const ( RolloutCompletedReason = "RolloutCompleted" // RolloutCompletedMessage is added when the rollout is completed RolloutCompletedMessage = "Rollout completed update to revision %d (%s): %s" + // RolloutNotCompletedReason is added in a rollout when it is completed. + RolloutNotCompletedReason = "RolloutNotCompleted" // RolloutNotCompletedMessage is added when the rollout is completed RolloutNotCompletedMessage = "Rollout not completed, started update to revision %d (%s)" diff --git a/utils/conditions/rollouts_test.go b/utils/conditions/rollouts_test.go index 4985b8f728..9a4d49d09e 100644 --- a/utils/conditions/rollouts_test.go +++ b/utils/conditions/rollouts_test.go @@ -350,7 +350,7 @@ func TestRolloutProgressing(t *testing.T) { } -func TestRolloutHealthyAndComplete(t *testing.T) { +func TestRolloutHealthyAndCompleted(t *testing.T) { rollout := func(desired, current, updated, available int32, correctObservedGeneration bool) *v1alpha1.Rollout { r := &v1alpha1.Rollout{ Spec: v1alpha1.RolloutSpec{