Skip to content

Commit 0e677c0

Browse files
committed
workloadscontroller: set generations if workload information is available
1 parent e5799cb commit 0e677c0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
corev1listers "k8s.io/client-go/listers/core/v1"
1818
"k8s.io/client-go/tools/cache"
1919
"k8s.io/client-go/util/workqueue"
20-
"k8s.io/utils/ptr"
2120

2221
operatorv1 "github.com/openshift/api/operator/v1"
2322
openshiftconfigclientv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
@@ -177,6 +176,17 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
177176
WithType(fmt.Sprintf("%sDeployment%s", c.conditionsPrefix, operatorv1.OperatorStatusTypeProgressing))
178177

179178
status := applyoperatorv1.OperatorStatus()
179+
if workload != nil {
180+
// The Hash field is not required since the LastGeneration field is enough to uniquely identify a Deployment's desired state
181+
status = status.WithGenerations(applyoperatorv1.GenerationStatus().
182+
WithGroup("apps").
183+
WithResource("deployments").
184+
WithNamespace(workload.Namespace).
185+
WithName(workload.Name).
186+
WithLastGeneration(workload.Generation),
187+
)
188+
}
189+
180190
defer func() {
181191
status = status.WithConditions(
182192
deploymentAvailableCondition,
@@ -330,15 +340,6 @@ func (c *Controller) updateOperatorStatus(ctx context.Context, previousStatus *o
330340
c.versionRecorder.SetVersion(operandName, c.targetOperandVersion)
331341
}
332342

333-
// set generations
334-
status = status.WithGenerations(&applyoperatorv1.GenerationStatusApplyConfiguration{
335-
Group: ptr.To("apps"),
336-
Resource: ptr.To("deployments"),
337-
Namespace: ptr.To(workload.Namespace),
338-
Name: ptr.To(workload.Name),
339-
LastGeneration: ptr.To(workload.Generation),
340-
})
341-
342343
if len(errs) > 0 {
343344
return kerrors.NewAggregate(errs)
344345
}

0 commit comments

Comments
 (0)