From 2c30eee92f8a1b461848cd0ad2b2848d908a69de Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 15 Jan 2019 19:14:36 +0100 Subject: [PATCH] kubelet: read immediately after creating the watcher if some events happen between the Read and while we set the watcher, we might miss them. Signed-off-by: Giuseppe Scrivano --- pkg/kubelet/kuberuntime/logs/logs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/kubelet/kuberuntime/logs/logs.go b/pkg/kubelet/kuberuntime/logs/logs.go index d37ed2a987..db88834001 100644 --- a/pkg/kubelet/kuberuntime/logs/logs.go +++ b/pkg/kubelet/kuberuntime/logs/logs.go @@ -316,6 +316,9 @@ func ReadLogs(ctx context.Context, path, containerID string, opts *LogOptions, r if err := watcher.Add(f.Name()); err != nil { return fmt.Errorf("failed to watch file %q: %v", f.Name(), err) } + // If we just created the watcher, try again to read as we might have missed + // the event. + continue } // Wait until the next log change. if found, err := waitLogs(ctx, containerID, watcher, runtimeService); !found {