From 52637bd3a764941529de5ac9dbdbff7db717bc4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:55:56 +0000 Subject: [PATCH] rebase: bump k8s.io/klog/v2 in the k8s-dependencies group Bumps the k8s-dependencies group with 1 update: [k8s.io/klog/v2](https://github.com/kubernetes/klog). Updates `k8s.io/klog/v2` from 2.130.0 to 2.130.1 - [Release notes](https://github.com/kubernetes/klog/releases) - [Changelog](https://github.com/kubernetes/klog/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes/klog/compare/v2.130.0...v2.130.1) --- updated-dependencies: - dependency-name: k8s.io/klog/v2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/k8s.io/klog/v2/klog.go | 77 ++++++++++++----------------------- vendor/modules.txt | 2 +- 4 files changed, 29 insertions(+), 56 deletions(-) diff --git a/go.mod b/go.mod index daa6a1910..66cb6cf67 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( k8s.io/apimachinery v0.30.2 k8s.io/client-go v12.0.0+incompatible k8s.io/cloud-provider v0.30.2 - k8s.io/klog/v2 v2.130.0 + k8s.io/klog/v2 v2.130.1 k8s.io/kubernetes v1.30.2 k8s.io/mount-utils v0.30.2 k8s.io/pod-security-admission v0.30.2 diff --git a/go.sum b/go.sum index 7fb5bee8e..04d8ee939 100644 --- a/go.sum +++ b/go.sum @@ -2638,8 +2638,8 @@ 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.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM= -k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kms v0.30.2 h1:VSZILO/tkzrz5Tu2j+yFQZ2Dc5JerQZX2GqhFJbQrfw= k8s.io/kms v0.30.2/go.mod h1:GrMurD0qk3G4yNgGcsCEmepqf9KyyIrTXYR2lyUOJC4= k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/vendor/k8s.io/klog/v2/klog.go b/vendor/k8s.io/klog/v2/klog.go index 16dcb3b9d..47ec9466a 100644 --- a/vendor/k8s.io/klog/v2/klog.go +++ b/vendor/k8s.io/klog/v2/klog.go @@ -404,13 +404,6 @@ func (t *traceLocation) Set(value string) error { return nil } -// flushSyncWriter is the interface satisfied by logging destinations. -type flushSyncWriter interface { - Flush() error - Sync() error - io.Writer -} - var logging loggingT var commandLine flag.FlagSet @@ -486,7 +479,7 @@ type settings struct { // Access to all of the following fields must be protected via a mutex. // file holds writer for each of the log types. - file [severity.NumSeverity]flushSyncWriter + file [severity.NumSeverity]io.Writer // flushInterval is the interval for periodic flushing. If zero, // the global default will be used. flushInterval time.Duration @@ -831,32 +824,12 @@ func (l *loggingT) printS(err error, s severity.Severity, depth int, msg string, buffer.PutBuffer(b) } -// redirectBuffer is used to set an alternate destination for the logs -type redirectBuffer struct { - w io.Writer -} - -func (rb *redirectBuffer) Sync() error { - return nil -} - -func (rb *redirectBuffer) Flush() error { - return nil -} - -func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) { - return rb.w.Write(bytes) -} - // SetOutput sets the output destination for all severities func SetOutput(w io.Writer) { logging.mu.Lock() defer logging.mu.Unlock() for s := severity.FatalLog; s >= severity.InfoLog; s-- { - rb := &redirectBuffer{ - w: w, - } - logging.file[s] = rb + logging.file[s] = w } } @@ -868,10 +841,7 @@ func SetOutputBySeverity(name string, w io.Writer) { if !ok { panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name)) } - rb := &redirectBuffer{ - w: w, - } - logging.file[sev] = rb + logging.file[sev] = w } // LogToStderr sets whether to log exclusively to stderr, bypassing outputs @@ -1011,8 +981,8 @@ func (l *loggingT) exit(err error) { logExitFunc(err) return } - files := l.flushAll() - l.syncAll(files) + needToSync := l.flushAll() + l.syncAll(needToSync) OsExit(2) } @@ -1029,10 +999,6 @@ type syncBuffer struct { maxbytes uint64 // The max number of bytes this syncBuffer.file can hold before cleaning up. } -func (sb *syncBuffer) Sync() error { - return sb.file.Sync() -} - // CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options. func CalculateMaxSize() uint64 { if logging.logFile != "" { @@ -1224,37 +1190,44 @@ func StartFlushDaemon(interval time.Duration) { // lockAndFlushAll is like flushAll but locks l.mu first. func (l *loggingT) lockAndFlushAll() { l.mu.Lock() - files := l.flushAll() + needToSync := l.flushAll() l.mu.Unlock() // Some environments are slow when syncing and holding the lock might cause contention. - l.syncAll(files) + l.syncAll(needToSync) } // flushAll flushes all the logs // l.mu is held. -func (l *loggingT) flushAll() []flushSyncWriter { - files := make([]flushSyncWriter, 0, severity.NumSeverity) +// +// The result is the number of files which need to be synced and the pointers to them. +func (l *loggingT) flushAll() fileArray { + var needToSync fileArray + // Flush from fatal down, in case there's trouble flushing. for s := severity.FatalLog; s >= severity.InfoLog; s-- { file := l.file[s] - if file != nil { - _ = file.Flush() // ignore error + if sb, ok := file.(*syncBuffer); ok && sb.file != nil { + _ = sb.Flush() // ignore error + needToSync.files[needToSync.num] = sb.file + needToSync.num++ } - files = append(files, file) } if logging.loggerOptions.flush != nil { logging.loggerOptions.flush() } - return files + return needToSync +} + +type fileArray struct { + num int + files [severity.NumSeverity]*os.File } // syncAll attempts to "sync" their data to disk. -func (l *loggingT) syncAll(files []flushSyncWriter) { +func (l *loggingT) syncAll(needToSync fileArray) { // Flush from fatal down, in case there's trouble flushing. - for _, file := range files { - if file != nil { - _ = file.Sync() // ignore error - } + for i := 0; i < needToSync.num; i++ { + _ = needToSync.files[i].Sync() // ignore error } } diff --git a/vendor/modules.txt b/vendor/modules.txt index c685467d1..9a0ac216a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1608,7 +1608,7 @@ k8s.io/controller-manager/pkg/features k8s.io/controller-manager/pkg/features/register k8s.io/controller-manager/pkg/leadermigration/config k8s.io/controller-manager/pkg/leadermigration/options -# k8s.io/klog/v2 v2.130.0 +# k8s.io/klog/v2 v2.130.1 ## explicit; go 1.18 k8s.io/klog/v2 k8s.io/klog/v2/internal/buffer