kubelet: force checking the log file every second

it seems fsnotify can miss some read events, blocking the kubelet to
receive more data from the log file.

If we end up waiting for events with fsnotify, force a read from the
log file every second so that are sure to not miss new data for longer
than that.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
k3s-v1.15.3
Giuseppe Scrivano 2019-01-16 21:54:14 +01:00
parent 341c2c0d1f
commit 8f68b281e4
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
1 changed files with 5 additions and 0 deletions

View File

@ -56,6 +56,9 @@ const (
// the container log. Kubelet should not keep following the log when the // the container log. Kubelet should not keep following the log when the
// container is not running. // container is not running.
stateCheckPeriod = 5 * time.Second stateCheckPeriod = 5 * time.Second
// logForceCheckPeriod is the period to check for a new read
logForceCheckPeriod = 1 * time.Second
) )
var ( var (
@ -426,6 +429,8 @@ func waitLogs(ctx context.Context, id string, w *fsnotify.Watcher, runtimeServic
return false, false, err return false, false, err
} }
errRetry-- errRetry--
case <-time.After(logForceCheckPeriod):
return true, false, nil
case <-time.After(stateCheckPeriod): case <-time.After(stateCheckPeriod):
if running, err := isContainerRunning(id, runtimeService); !running { if running, err := isContainerRunning(id, runtimeService); !running {
return false, false, err return false, false, err