diff --git a/go.mod b/go.mod index d48ad01696b0..ada9f12c1ea3 100644 --- a/go.mod +++ b/go.mod @@ -101,6 +101,7 @@ require ( github.com/go-test/deep v1.0.7 github.com/golang/mock v1.6.0 github.com/google/cadvisor v0.49.0 + github.com/google/go-containerregistry v0.20.2 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.1 @@ -168,7 +169,6 @@ require ( k8s.io/kubernetes v1.30.5 k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 sigs.k8s.io/yaml v1.4.0 - github.com/google/go-containerregistry v0.20.2 ) require ( @@ -246,6 +246,7 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect + github.com/fvbommel/sortorder v1.1.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/go-errors/errors v1.4.2 // indirect github.com/go-jose/go-jose/v4 v4.0.2 // indirect diff --git a/pkg/agent/containerd/watcher.go b/pkg/agent/containerd/watcher.go index 81d303699e2f..156d3d3e486a 100644 --- a/pkg/agent/containerd/watcher.go +++ b/pkg/agent/containerd/watcher.go @@ -24,7 +24,7 @@ import ( type Watcher struct { watcher *fsnotify.Watcher filesCache map[string]fs.FileInfo - workqueue workqueue.TypedDelayingInterface[string] + workqueue workqueue.DelayingInterface } func CreateWatcher() (*Watcher, error) { @@ -36,7 +36,7 @@ func CreateWatcher() (*Watcher, error) { return &Watcher{ watcher: watcher, filesCache: make(map[string]fs.FileInfo), - workqueue: workqueue.TypedNewDelayingQueue[string](), + workqueue: workqueue.NewDelayingQueue(), }, nil } @@ -136,7 +136,19 @@ func (w *Watcher) processNextEventForImages(ctx context.Context, cfg *config.Nod return true } -func (w *Watcher) processImageEvent(ctx context.Context, key string, cfg *config.Node, client *containerd.Client, imageClient runtimeapi.ImageServiceClient) error { +func (w *Watcher) processImageEvent(ctx context.Context, obj interface{}, cfg *config.Node, client *containerd.Client, imageClient runtimeapi.ImageServiceClient) error { + var ( + key string + ok bool + ) + + defer w.workqueue.Done(obj) + + if key, ok = obj.(string); !ok { + logrus.Errorf("expected string in workqueue but got %#v", obj) + return nil + } + defer w.workqueue.Done(key) file, err := os.Stat(key)