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 <gscrivan@redhat.com>
k3s-v1.15.3
Giuseppe Scrivano 2019-01-15 19:14:36 +01:00
parent 615c491040
commit 2c30eee92f
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
1 changed files with 3 additions and 0 deletions

View File

@ -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 {