Skip to content

Commit ed9ab11

Browse files
committed
workloadscontroller: don't overwrite degraded condition if it's already set
1 parent 0e677c0 commit ed9ab11

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/operator/apiserver/controller/workload/workload.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
241241
WithStatus(operatorv1.ConditionTrue).
242242
WithReason("SyncError").
243243
WithMessage(message)
244+
} else if workload == nil {
245+
workloadDegradedCondition = workloadDegradedCondition.
246+
WithStatus(operatorv1.ConditionTrue).
247+
WithReason("NoDeployment").
248+
WithMessage(fmt.Sprintf("deployment/%s: could not be retrieved", c.targetNamespace))
244249
} else {
245250
workloadDegradedCondition = workloadDegradedCondition.
246251
WithStatus(operatorv1.ConditionFalse)
@@ -263,11 +268,6 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
263268
WithReason("NoDeployment").
264269
WithMessage(message)
265270

266-
workloadDegradedCondition = workloadDegradedCondition.
267-
WithStatus(operatorv1.ConditionTrue).
268-
WithReason("NoDeployment").
269-
WithMessage(message)
270-
271271
return kerrors.NewAggregate(errs)
272272
}
273273

pkg/operator/apiserver/controller/workload/workload_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ func TestUpdateOperatorStatus(t *testing.T) {
107107
{
108108
Type: fmt.Sprintf("%sWorkloadDegraded", defaultControllerName),
109109
Status: operatorv1.ConditionTrue,
110-
Reason: "NoDeployment",
111-
Message: "deployment/: could not be retrieved",
110+
Message: "nasty error\n",
111+
Reason: "SyncError",
112112
},
113113
{
114114
Type: fmt.Sprintf("%sDeploymentDegraded", defaultControllerName),

0 commit comments

Comments
 (0)