diff --git a/pkg/agent/containerd/watcher.go b/pkg/agent/containerd/watcher.go index 2dd8d52baf..eaf0600b22 100644 --- a/pkg/agent/containerd/watcher.go +++ b/pkg/agent/containerd/watcher.go @@ -50,6 +50,16 @@ func isFileSupported(path string) bool { return false } +func isTarball(path string) bool { + for _, ext := range tarfile.SupportedExtensions { + if strings.HasSuffix(path, ext) { + return true + } + } + + return false +} + func (w *Watcher) HandleWatch(path string) error { if err := w.watcher.Add(path); err != nil { return errors.Wrap(err, fmt.Sprintf("failed to watch from %s directory: %v", path, err)) @@ -129,6 +139,10 @@ func (w *Watcher) processNextEventForImages(ctx context.Context, cfg *config.Nod return false } + if isTarball(event.Name) { + time.Sleep(1 * time.Second) + } + if err := w.processImageEvent(ctx, event, cfg, client, imageClient); err != nil { logrus.Errorf("Failed to process image event: %v", err) } @@ -225,7 +239,6 @@ func (w *Watcher) processImageEvent(ctx context.Context, event fsnotify.Event, c w.filesMap[event.Name] = info logrus.Debugf("File added to watcher controller: %s", event.Name) - start := time.Now() if err := preloadFile(ctx, cfg, client, imageClient, event.Name); err != nil { logrus.Errorf("Error encountered while importing %s: %v", event.Name, err)