From 3f36fe0fdabc16013eaabf2cbf845d476716856b Mon Sep 17 00:00:00 2001 From: Vitor Savian Date: Thu, 21 Nov 2024 15:34:29 -0300 Subject: [PATCH] Fix EOF error log when importing tarball files Signed-off-by: Vitor Savian --- pkg/agent/containerd/watcher.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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)