Skip to content

Commit

Permalink
workloadscontroller: don't overwrite degraded condition if it's alrea…
Browse files Browse the repository at this point in the history
…dy set
  • Loading branch information
bertinatto committed Oct 21, 2024
1 parent 0e677c0 commit ed9ab11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pkg/operator/apiserver/controller/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
WithStatus(operatorv1.ConditionTrue).
WithReason("SyncError").
WithMessage(message)
} else if workload == nil {
workloadDegradedCondition = workloadDegradedCondition.
WithStatus(operatorv1.ConditionTrue).
WithReason("NoDeployment").
WithMessage(fmt.Sprintf("deployment/%s: could not be retrieved", c.targetNamespace))
} else {
workloadDegradedCondition = workloadDegradedCondition.
WithStatus(operatorv1.ConditionFalse)
Expand All @@ -263,11 +268,6 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
WithReason("NoDeployment").
WithMessage(message)

workloadDegradedCondition = workloadDegradedCondition.
WithStatus(operatorv1.ConditionTrue).
WithReason("NoDeployment").
WithMessage(message)

return kerrors.NewAggregate(errs)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/apiserver/controller/workload/workload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func TestUpdateOperatorStatus(t *testing.T) {
{
Type: fmt.Sprintf("%sWorkloadDegraded", defaultControllerName),
Status: operatorv1.ConditionTrue,
Reason: "NoDeployment",
Message: "deployment/: could not be retrieved",
Message: "nasty error\n",
Reason: "SyncError",
},
{
Type: fmt.Sprintf("%sDeploymentDegraded", defaultControllerName),
Expand Down

0 comments on commit ed9ab11

Please sign in to comment.