Skip to content

Commit

Permalink
workload controller: delays reporting degraded condition when progres…
Browse files Browse the repository at this point in the history
…sing > 15 minutes
  • Loading branch information
p0lyn0mial committed Jun 22, 2021
1 parent ef142b5 commit fd00767
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/operator/apiserver/controller/workload/workload.go
Expand Up @@ -323,9 +323,11 @@ func (c *Controller) updateOperatorStatus(previousStatus *operatorv1.OperatorSta
return nil
}

// isUpdatingTooLong determines if updating operands takes too long.
// it returns true if the progressing condition has been set to True for at least 15 minutes
func isUpdatingTooLong(operatorStatus *operatorv1.OperatorStatus, progressingConditionType string) (bool, error) {
progressing := v1helpers.FindOperatorCondition(operatorStatus.Conditions, progressingConditionType)
return progressing != nil && progressing.Status == operatorv1.ConditionTrue && time.Now().After(progressing.LastTransitionTime.Add(5*time.Minute)), nil
return progressing != nil && progressing.Status == operatorv1.ConditionTrue && time.Now().After(progressing.LastTransitionTime.Add(15*time.Minute)), nil
}

// EnsureAtMostOnePodPerNode updates the deployment spec to prevent more than
Expand Down
Expand Up @@ -140,7 +140,7 @@ func TestUpdateOperatorStatus(t *testing.T) {
Type: fmt.Sprintf("%sDeployment%s", defaultControllerName, operatorv1.OperatorStatusTypeProgressing),
Status: operatorv1.ConditionTrue,
Reason: "PodsUpdating",
LastTransitionTime: metav1.NewTime(time.Now().Add(-6 * time.Minute)),
LastTransitionTime: metav1.NewTime(time.Now().Add(-16 * time.Minute)),
},
},
validateOperatorStatus: func(actualStatus *operatorv1.OperatorStatus) error {
Expand Down

0 comments on commit fd00767

Please sign in to comment.