Skip to content

Commit

Permalink
Modify sync.go and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khhirani committed Mar 31, 2021
1 parent 9c28396 commit dec15f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions rollout/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ func TestDoNotCreateBackgroundAnalysisRunAfterInconclusiveRun(t *testing.T) {
}}
pausedCondition, _ := newProgressingCondition(conditions.PausedRolloutReason, r2, "")
conditions.SetRolloutCondition(&r2.Status, pausedCondition)
// TODO: Add Pause Condition

f.rolloutLister = append(f.rolloutLister, r2)
f.analysisTemplateLister = append(f.analysisTemplateLister, at)
Expand Down
35 changes: 18 additions & 17 deletions rollout/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,33 +483,34 @@ func (c *rolloutContext) cleanupRollouts(oldRSs []*appsv1.ReplicaSet) error {
// These conditions are needed so that we won't accidentally report lack of progress for resumed rollouts
// that were paused for longer than progressDeadlineSeconds.
func (c *rolloutContext) checkPausedConditions() error {
cond := conditions.GetRolloutCondition(c.rollout.Status, v1alpha1.RolloutProgressing)
pauseCond := conditions.GetRolloutCondition(c.rollout.Status, v1alpha1.RolloutPaused)
pausedCondExists := cond != nil && cond.Reason == conditions.PausedRolloutReason

// Progressing condition
progCond := conditions.GetRolloutCondition(c.rollout.Status, v1alpha1.RolloutProgressing)
progCondPaused := progCond != nil && progCond.Reason == conditions.PausedRolloutReason
isPaused := len(c.rollout.Status.PauseConditions) > 0 || c.rollout.Spec.Paused
var updatedConditions []*v1alpha1.RolloutCondition
if isPaused && !pausedCondExists {
// Add extra pause condition
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutPaused, corev1.ConditionTrue, conditions.PausedRolloutReason, conditions.PausedRolloutMessage))
if isPaused && !progCondPaused {
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionUnknown, conditions.PausedRolloutReason, conditions.PausedRolloutMessage))
} else if !isPaused && pausedCondExists {
if pauseCond != nil {
// If pause condition exists in conditionList, set to False
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutPaused, corev1.ConditionFalse, conditions.PausedRolloutReason, conditions.PausedRolloutMessage))
}
} else if !isPaused && progCondPaused {
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionUnknown, conditions.ResumedRolloutReason, conditions.ResumeRolloutMessage))
}

abortCondExists := cond != nil && cond.Reason == conditions.RolloutAbortedReason
abortCondExists := progCond != nil && progCond.Reason == conditions.RolloutAbortedReason
if !c.rollout.Status.Abort && abortCondExists {
//if pauseCond != nil {
// // If pause condition exists in conditionList, set to False
// updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutPaused, corev1.ConditionFalse, conditions.PausedRolloutReason, conditions.PausedRolloutMessage))
//}
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionUnknown, conditions.RolloutRetryReason, conditions.RolloutRetryMessage))
}

pauseCond := conditions.GetRolloutCondition(c.rollout.Status, v1alpha1.RolloutPaused)
pausedCondTrue := pauseCond != nil && pauseCond.Status == corev1.ConditionTrue

if (isPaused && !abortCondExists) != pausedCondTrue {
condStatus := corev1.ConditionFalse
// Add extra pause condition
if isPaused {
condStatus = corev1.ConditionTrue
}
updatedConditions = append(updatedConditions, conditions.NewRolloutCondition(v1alpha1.RolloutPaused, condStatus, conditions.PausedRolloutReason, conditions.PausedRolloutMessage))
}

if len(updatedConditions) == 0 {
return nil
}
Expand Down

0 comments on commit dec15f9

Please sign in to comment.