Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/openshift/client-go/config/clientset/versioned/scheme"
configinformersv1 "github.com/openshift/client-go/config/informers/externalversions/config/v1"
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
"github.com/openshift/cluster-version-operator/lib/resourceapply"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -25,6 +24,8 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"

"github.com/openshift/cluster-version-operator/lib/resourceapply"
)

const (
Expand Down Expand Up @@ -114,9 +115,9 @@ func (ctrl *Controller) Run(ctx context.Context, workers int) error {
func (ctrl *Controller) eventHandler() cache.ResourceEventHandler {
key := fmt.Sprintf("%s/%s", ctrl.namespace, ctrl.name)
return cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) { ctrl.queue.Add(key) },
UpdateFunc: func(old, new interface{}) { ctrl.queue.Add(key) },
DeleteFunc: func(obj interface{}) { ctrl.queue.Add(key) },
AddFunc: func(_ interface{}) { ctrl.queue.Add(key) },
UpdateFunc: func(_, _ interface{}) { ctrl.queue.Add(key) },
DeleteFunc: func(_ interface{}) { ctrl.queue.Add(key) },
}
}

Expand Down
15 changes: 8 additions & 7 deletions pkg/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
clientset "github.com/openshift/client-go/config/clientset/versioned"
configinformersv1 "github.com/openshift/client-go/config/informers/externalversions/config/v1"
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
"github.com/openshift/library-go/pkg/manifest"
"github.com/openshift/library-go/pkg/verify"
"github.com/openshift/library-go/pkg/verify/store/configmap"
"github.com/openshift/library-go/pkg/verify/store/sigstore"

"github.com/openshift/cluster-version-operator/lib/capability"
"github.com/openshift/cluster-version-operator/lib/resourcebuilder"
"github.com/openshift/cluster-version-operator/lib/validation"
Expand All @@ -42,10 +47,6 @@ import (
"github.com/openshift/cluster-version-operator/pkg/payload"
"github.com/openshift/cluster-version-operator/pkg/payload/precondition"
preconditioncv "github.com/openshift/cluster-version-operator/pkg/payload/precondition/clusterversion"
"github.com/openshift/library-go/pkg/manifest"
"github.com/openshift/library-go/pkg/verify"
"github.com/openshift/library-go/pkg/verify/store/configmap"
"github.com/openshift/library-go/pkg/verify/store/sigstore"
)

const (
Expand Down Expand Up @@ -491,17 +492,17 @@ func (optr *Operator) queueKey() string {
func (optr *Operator) clusterVersionEventHandler() cache.ResourceEventHandler {
workQueueKey := optr.queueKey()
return cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
AddFunc: func(_ interface{}) {
optr.queue.Add(workQueueKey)
optr.availableUpdatesQueue.Add(workQueueKey)
optr.upgradeableQueue.Add(workQueueKey)
},
UpdateFunc: func(old, new interface{}) {
UpdateFunc: func(_, _ interface{}) {
optr.queue.Add(workQueueKey)
optr.availableUpdatesQueue.Add(workQueueKey)
optr.upgradeableQueue.Add(workQueueKey)
},
DeleteFunc: func(obj interface{}) {
DeleteFunc: func(_ interface{}) {
optr.queue.Add(workQueueKey)
},
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/cvo/upgradeable.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,14 @@ func (optr *Operator) updateFunc(oldObj, newObj interface{}) {
}

func (optr *Operator) deleteFunc(obj interface{}) {
cm := obj.(*corev1.ConfigMap)
if tombstone, ok := obj.(cache.DeletedFinalStateUnknown); ok {
obj = tombstone
}
cm, ok := obj.(*corev1.ConfigMap)
if !ok {
klog.Errorf("Unexpected type %T", obj)
return
}
Copy link
Member

@petr-muller petr-muller Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

I have looked into our other DeleteFunc handlers and it seems like none of them need a similar treatment because they do not use the object from the informer but just queue something else for processing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And just added 2763543 to make that more obvious.

if cm.Name == internal.AdminGatesConfigMap || cm.Name == internal.AdminAcksConfigMap {
klog.V(2).Infof("ConfigMap %s/%s deleted.", cm.Namespace, cm.Name)
optr.setUpgradableConditionsIfSynced()
Expand Down
6 changes: 3 additions & 3 deletions pkg/featurechangestopper/featurechangestopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func New(

c.queue.Add("cluster") // seed an initial sync, in case startingRequiredFeatureSet is wrong
if _, err := featureGateInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
AddFunc: func(_ interface{}) {
c.queue.Add("cluster")
},
UpdateFunc: func(old interface{}, new interface{}) {
UpdateFunc: func(_ interface{}, _ interface{}) {
c.queue.Add("cluster")
},
DeleteFunc: func(obj interface{}) {
DeleteFunc: func(_ interface{}) {
c.queue.Add("cluster")
},
}); err != nil {
Expand Down