diff --git a/controller.go b/controller.go index f2e66c30..efbd391e 100644 --- a/controller.go +++ b/controller.go @@ -204,27 +204,27 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool { } // We wrap this block in a func so we can defer c.workqueue.Done. - err := func(key string) error { + err := func() error { // We call Done here so the workqueue knows we have finished // processing this item. We also must remember to call Forget if we // do not want this work item being re-queued. For example, we do // not call Forget if a transient error occurs, instead the item is // put back on the workqueue and attempted again after a back-off // period. - defer c.workqueue.Done(key) + defer c.workqueue.Done(obj) // Run the syncHandler, passing it the namespace/name string of the // Foo resource to be synced. - if err := c.syncHandler(ctx, key); err != nil { + if err := c.syncHandler(ctx, obj); err != nil { // Put the item back on the workqueue to handle any transient errors. - c.workqueue.AddRateLimited(key) - return fmt.Errorf("error syncing '%s': %s, requeuing", key, err.Error()) + c.workqueue.AddRateLimited(obj) + return fmt.Errorf("error syncing '%s': %s, requeuing", obj, err.Error()) } // Finally, if no error occurs we Forget this item so it does not // get queued again until another change happens. c.workqueue.Forget(obj) - logger.Info("Successfully synced", "resourceName", key) + logger.Info("Successfully synced", "resourceName", obj) return nil - }(obj) + }() if err != nil { utilruntime.HandleError(err) diff --git a/go.mod b/go.mod index ea65291e..b370136a 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ go 1.22.0 require ( golang.org/x/time v0.3.0 k8s.io/api v0.0.0-20240531003526-c114cd746b5a - k8s.io/apimachinery v0.0.0-20240530220031-733a95eb52c3 - k8s.io/client-go v0.0.0-20240531003927-52e5651101ed + k8s.io/apimachinery v0.0.0-20240603234208-703232ea6da4 + k8s.io/client-go v0.0.0-20240604003933-7c6e307a725f k8s.io/code-generator v0.0.0-20240531004635-2ec7af029e9a k8s.io/klog/v2 v2.120.1 ) diff --git a/go.sum b/go.sum index a9d6553f..8a211db9 100644 --- a/go.sum +++ b/go.sum @@ -148,10 +148,10 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.0.0-20240531003526-c114cd746b5a h1:P8nQ3iz4FxeKN26Y8fz9qoEkUZy/DkQPtBmkVyriAS0= k8s.io/api v0.0.0-20240531003526-c114cd746b5a/go.mod h1:2VfykmUr8OqDStfcJWPvSW182MtoxAMeWsJHXwxqzXo= -k8s.io/apimachinery v0.0.0-20240530220031-733a95eb52c3 h1:wKdO12WPN63kX3M6aJQqn6IaacuD1sZw1CswMGfjmJk= -k8s.io/apimachinery v0.0.0-20240530220031-733a95eb52c3/go.mod h1:ClkKrTMwhmMjgsEHpX2w3F+YKj0ctDOaAxqL7clxG0U= -k8s.io/client-go v0.0.0-20240531003927-52e5651101ed h1:0caFt79cyI5V9Kx+Mgx+1Ew7Y7P5Xbs2JTg6Obt+UeQ= -k8s.io/client-go v0.0.0-20240531003927-52e5651101ed/go.mod h1:eKPERGqe84mnn/p9CKDZxsnjDJAMSlwr4L/be7kWLh0= +k8s.io/apimachinery v0.0.0-20240603234208-703232ea6da4 h1:On2XjWF6loaEJ/GLZH+ZyovYHWfOZUgl9qUdC8Mn05o= +k8s.io/apimachinery v0.0.0-20240603234208-703232ea6da4/go.mod h1:ClkKrTMwhmMjgsEHpX2w3F+YKj0ctDOaAxqL7clxG0U= +k8s.io/client-go v0.0.0-20240604003933-7c6e307a725f h1:7A1fNtVKUFjDecsZm2r/Ec3DtdVhuylFo6Hst/cD+HI= +k8s.io/client-go v0.0.0-20240604003933-7c6e307a725f/go.mod h1:5farkvv+2p9AXn5JduImtwwykMh2JcZQO9mlYXp2qEA= k8s.io/code-generator v0.0.0-20240531004635-2ec7af029e9a h1:BEO+bjC1wFnvpUTswqNXY69EsVjFTsm+oJT+P+v7s6Q= k8s.io/code-generator v0.0.0-20240531004635-2ec7af029e9a/go.mod h1:Atvd4cTf/ejISaIw7BTDEj+yW3kqFMoSa/R8rG5aPRU= k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo=