Merge pull request #15209 from cpuguy83/15199_fix_tailing_more_than_available
Ensure reader position is at the end after tailing Upstream-commit: d080d262b3f6c56f159f3ac714f207bac31c9b8e Component: engine
This commit is contained in:
@ -267,7 +267,8 @@ func (l *JSONFileLogger) readLogs(logWatcher *logger.LogWatcher, config logger.R
|
||||
if !config.Follow {
|
||||
return
|
||||
}
|
||||
if config.Tail == 0 {
|
||||
|
||||
if config.Tail >= 0 {
|
||||
latestFile.Seek(0, os.SEEK_END)
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ package logger
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/timeutils"
|
||||
@ -58,6 +59,7 @@ type LogWatcher struct {
|
||||
// For sending error messages that occur while while reading logs.
|
||||
Err chan error
|
||||
closeNotifier chan struct{}
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
// NewLogWatcher returns a new LogWatcher.
|
||||
@ -71,7 +73,12 @@ func NewLogWatcher() *LogWatcher {
|
||||
|
||||
// Close notifies the underlying log reader to stop.
|
||||
func (w *LogWatcher) Close() {
|
||||
close(w.closeNotifier)
|
||||
// only close if not already closed
|
||||
select {
|
||||
case <-w.closeNotifier:
|
||||
default:
|
||||
close(w.closeNotifier)
|
||||
}
|
||||
}
|
||||
|
||||
// WatchClose returns a channel receiver that receives notification
|
||||
|
||||
Reference in New Issue
Block a user