Skip to content

Commit

Permalink
Merge pull request #795 from openshift-cherrypick-robot/cherry-pick-7…
Browse files Browse the repository at this point in the history
…90-to-release-4.11

[release-4.11] Bug 2110958: Use actualDaemonSet for SetDaemonSetGeneration
  • Loading branch information
openshift-merge-robot committed Sep 2, 2022
2 parents 609bea3 + f0d909e commit 8e2d96f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 10 additions & 1 deletion pkg/operator/nodecadaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ func (c *NodeCADaemonController) processNextWorkItem() bool {
}
defer c.queue.Done(obj)

klog.V(4).Infof("get event from workqueue")
klog.V(4).Infof("get event from workqueue: %s", obj)

// the workqueueKey we reference here is different than the one we use in eventHandler
// use that to identify we are processing an item that was added back to the queue
// can remove if not useful but curious why this didn't seem to be working for the
// caches not synced error
if obj == workqueueKey {
klog.V(2).Infof("NodeCADaemonController processing requeued item %s", obj)
}

if err := c.sync(); err != nil {
c.queue.AddRateLimited(workqueueKey)
klog.Errorf("NodeCADaemonController: unable to sync: %s, requeuing", err)
Expand Down
17 changes: 8 additions & 9 deletions pkg/resource/nodecadaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
"github.com/openshift/library-go/pkg/operator/v1helpers"

"github.com/openshift/cluster-image-registry-operator/bindata"
assets "github.com/openshift/cluster-image-registry-operator/bindata"
"github.com/openshift/cluster-image-registry-operator/pkg/defaults"
)

Expand Down Expand Up @@ -70,27 +70,26 @@ func (ds *generatorNodeCADaemonSet) Create() (runtime.Object, error) {
}

func (ds *generatorNodeCADaemonSet) Update(o runtime.Object) (runtime.Object, bool, error) {
daemonSet := ds.expected()
desiredDaemonSet := ds.expected()

_, opStatus, _, err := ds.operatorClient.GetOperatorState()
if err != nil {
return nil, false, err
}

dep, updated, err := resourceapply.ApplyDaemonSet(
actualDaemonSet, updated, err := resourceapply.ApplyDaemonSet(
context.TODO(),
ds.client,
ds.recorder,
daemonSet,
resourcemerge.ExpectedDaemonSetGeneration(daemonSet, opStatus.Generations),
desiredDaemonSet,
resourcemerge.ExpectedDaemonSetGeneration(desiredDaemonSet, opStatus.Generations),
)
if err != nil {
return o, updated, err
}

if updated {
updateStatusFn := func(newStatus *operatorv1.OperatorStatus) error {
resourcemerge.SetDaemonSetGeneration(&newStatus.Generations, daemonSet)
resourcemerge.SetDaemonSetGeneration(&newStatus.Generations, actualDaemonSet)
return nil
}

Expand All @@ -100,11 +99,11 @@ func (ds *generatorNodeCADaemonSet) Update(o runtime.Object) (runtime.Object, bo
updateStatusFn,
)
if err != nil {
return dep, updated, err
return actualDaemonSet, updated, err
}
}

return dep, updated, nil
return actualDaemonSet, updated, nil
}

func (ds *generatorNodeCADaemonSet) Delete(opts metav1.DeleteOptions) error {
Expand Down

0 comments on commit 8e2d96f

Please sign in to comment.