diff --git a/go.mod b/go.mod index d830bb3501..69be83604a 100644 --- a/go.mod +++ b/go.mod @@ -94,7 +94,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect k8s.io/component-base v0.23.4 // indirect - k8s.io/klog/v2 v2.50.1 + k8s.io/klog/v2 v2.50.2 k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect ) diff --git a/go.sum b/go.sum index 711674da35..e15cc72395 100644 --- a/go.sum +++ b/go.sum @@ -1518,8 +1518,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/klog/v2 v2.50.1 h1:GOi3WCd4+k04xAn20lhabnsgaqteBeUzjmPNz/w4GjE= -k8s.io/klog/v2 v2.50.1/go.mod h1:N3kgBtsFxMb4nQ0eBDgbHEt/dtxBuTkSFQ+7K5OUoz4= +k8s.io/klog/v2 v2.50.2 h1:OsuacU5nfUhtQY1ictYdOEzkUoP5zkZ61i8F67Ch6W0= +k8s.io/klog/v2 v2.50.2/go.mod h1:N3kgBtsFxMb4nQ0eBDgbHEt/dtxBuTkSFQ+7K5OUoz4= k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 h1:E3J9oCLlaobFUqsjG9DfKbP2BmgwBL2p7pn0A3dG9W4= diff --git a/vendor/k8s.io/klog/v2/klog.go b/vendor/k8s.io/klog/v2/klog.go index 15710be3fe..bb6f64be49 100644 --- a/vendor/k8s.io/klog/v2/klog.go +++ b/vendor/k8s.io/klog/v2/klog.go @@ -395,7 +395,7 @@ func init() { logging.addDirHeader = false logging.skipLogHeaders = false logging.oneOutput = false - logging.flushD = newFlushDaemon(flushInterval, logging.lockAndFlushAll, nil) + logging.flushD = newFlushDaemon(logging.lockAndFlushAll, nil) } // InitFlags is for explicitly initializing the flags. @@ -449,6 +449,9 @@ type loggingT struct { file [severity.NumSeverity]flushSyncWriter // flushD holds a flushDaemon that frequently flushes log file buffers. flushD *flushDaemon + // flushInterval is the interval for periodic flushing. If zero, + // the global default will be used. + flushInterval time.Duration // pcs is used in V to avoid an allocation when computing the caller's PC. pcs [1]uintptr // vmap is a cache of the V Level for each V() call site, identified by PC. @@ -976,7 +979,11 @@ const bufferSize = 256 * 1024 // createFiles creates all the log files for severity from sev down to infoLog. // l.mu is held. func (l *loggingT) createFiles(sev severity.Severity) error { - l.flushD.run() + interval := l.flushInterval + if interval == 0 { + interval = flushInterval + } + l.flushD.run(interval) now := time.Now() // Files are created in decreasing severity order, so as soon as we find one // has already been created, we can stop. @@ -1000,7 +1007,6 @@ const flushInterval = 5 * time.Second type flushDaemon struct { mu sync.Mutex clock clock.WithTicker - interval time.Duration flush func() stopC chan struct{} stopDone chan struct{} @@ -1008,20 +1014,19 @@ type flushDaemon struct { // newFlushDaemon returns a new flushDaemon. If the passed clock is nil, a // clock.RealClock is used. -func newFlushDaemon(interval time.Duration, flush func(), tickClock clock.WithTicker) *flushDaemon { +func newFlushDaemon(flush func(), tickClock clock.WithTicker) *flushDaemon { if tickClock == nil { tickClock = clock.RealClock{} } return &flushDaemon{ - interval: interval, - flush: flush, - clock: tickClock, + flush: flush, + clock: tickClock, } } // run starts a goroutine that periodically calls the daemons flush function. // Calling run on an already running daemon will have no effect. -func (f *flushDaemon) run() { +func (f *flushDaemon) run(interval time.Duration) { f.mu.Lock() defer f.mu.Unlock() @@ -1032,7 +1037,7 @@ func (f *flushDaemon) run() { f.stopC = make(chan struct{}, 1) f.stopDone = make(chan struct{}, 1) - ticker := f.clock.NewTicker(f.interval) + ticker := f.clock.NewTicker(interval) go func() { defer ticker.Stop() defer func() { f.stopDone <- struct{}{} }() @@ -1079,6 +1084,13 @@ func StopFlushDaemon() { logging.flushD.stop() } +// StartFlushDaemon ensures that the flush daemon runs with the given delay +// between flush calls. If it is already running, it gets restarted. +func StartFlushDaemon(interval time.Duration) { + StopFlushDaemon() + logging.flushD.run(interval) +} + // lockAndFlushAll is like flushAll but locks l.mu first. func (l *loggingT) lockAndFlushAll() { l.mu.Lock() diff --git a/vendor/modules.txt b/vendor/modules.txt index b182d6e863..fb6ab63509 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -887,7 +887,7 @@ k8s.io/component-base/config/v1alpha1 # k8s.io/klog v1.0.0 ## explicit; go 1.12 k8s.io/klog -# k8s.io/klog/v2 v2.50.1 +# k8s.io/klog/v2 v2.50.2 ## explicit; go 1.13 k8s.io/klog/v2 k8s.io/klog/v2/internal/buffer