From a63ca6749b9ff8409945b4b9e603b41d12992c44 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 22:19:27 +0200 Subject: [PATCH 1/9] Revert formatting changes --- pkg/kubelet/config/file.go | 11 +---------- pkg/kubelet/config/flags.go | 16 ++++++++++++---- pkg/kubelet/config/mux.go | 5 ++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/pkg/kubelet/config/file.go b/pkg/kubelet/config/file.go index 79e2af6ed62..20237b21bd4 100644 --- a/pkg/kubelet/config/file.go +++ b/pkg/kubelet/config/file.go @@ -34,20 +34,11 @@ import ( utilio "k8s.io/utils/io" ) -type podEventType int - const ( - podAdd podEventType = iota - podModify - podDelete - eventBufferLen = 10 ) -type watchEvent struct { - fileName string - eventType podEventType -} +type watchEvent struct{} type sourceFile struct { path string diff --git a/pkg/kubelet/config/flags.go b/pkg/kubelet/config/flags.go index 4ff13cacf0a..648eeb1d6b6 100644 --- a/pkg/kubelet/config/flags.go +++ b/pkg/kubelet/config/flags.go @@ -17,8 +17,6 @@ limitations under the License. package config import ( - "fmt" - "github.com/spf13/pflag" ) @@ -54,6 +52,16 @@ func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) { _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") // Image credential provider settings. - fs.StringVar(&s.ImageCredentialProviderConfigFile, "image-credential-provider-config", s.ImageCredentialProviderConfigFile, "The path to the credential provider plugin config file.") - fs.StringVar(&s.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", s.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.") + fs.StringVar( + &s.ImageCredentialProviderConfigFile, + "image-credential-provider-config", + s.ImageCredentialProviderConfigFile, + "The path to the credential provider plugin config file.", + ) + fs.StringVar( + &s.ImageCredentialProviderBinDir, + "image-credential-provider-bin-dir", + s.ImageCredentialProviderBinDir, + "The path to the directory where credential provider plugin binaries are located.", + ) } diff --git a/pkg/kubelet/config/mux.go b/pkg/kubelet/config/mux.go index b2bacff5f38..a2b3e1e0a5f 100644 --- a/pkg/kubelet/config/mux.go +++ b/pkg/kubelet/config/mux.go @@ -21,6 +21,7 @@ import ( "sync" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog/v2" ) type merger interface { @@ -75,6 +76,8 @@ func (m *mux) ChannelWithContext(ctx context.Context, source string) chan interf func (m *mux) listen(source string, listenChannel <-chan interface{}) { for update := range listenChannel { - m.merger.Merge(source, update) + if err := m.merger.Merge(source, update); err != nil { + klog.InfoS("failed merging update", "err", err) + } } } From 7d25a03ee3570657c64098ded1252e0a75a76c3d Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Fri, 2 Feb 2024 15:35:14 +0000 Subject: [PATCH 2/9] add: information about endpoint connection when auth handshake fails --- .../google.golang.org/grpc/internal/transport/http2_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 3c63c706986..43f80aa5c0f 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -286,7 +286,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts if transportCreds != nil { conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn) if err != nil { - return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err) + return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed for %s: %v", addr.ServerName, err) } for _, cd := range perRPCCreds { if cd.RequireTransportSecurity() { From 86f7f1dc7bf5763b76deb3087a23296710660447 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Thu, 18 Apr 2024 21:04:16 +0200 Subject: [PATCH 3/9] removed unused vars and improved readability --- pkg/kubelet/config/file.go | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkg/kubelet/config/file.go b/pkg/kubelet/config/file.go index 20237b21bd4..670804658e8 100644 --- a/pkg/kubelet/config/file.go +++ b/pkg/kubelet/config/file.go @@ -51,7 +51,12 @@ type sourceFile struct { } // NewSourceFile watches a config file for changes. -func NewSourceFile(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) { +func NewSourceFile( + path string, + nodeName types.NodeName, + period time.Duration, + updates chan<- interface{}, +) { // "github.com/sigma/go-inotify" requires a path without trailing "/" path = strings.TrimRight(path, string(os.PathSeparator)) @@ -60,7 +65,12 @@ func NewSourceFile(path string, nodeName types.NodeName, period time.Duration, u config.run() } -func newSourceFile(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) *sourceFile { +func newSourceFile( + path string, + nodeName types.NodeName, + period time.Duration, + updates chan<- interface{}, +) *sourceFile { send := func(objs []interface{}) { var pods []*v1.Pod for _, o := range objs { @@ -170,7 +180,12 @@ func (s *sourceFile) extractFromDir(name string) ([]*v1.Pod, error) { switch { case statInfo.Mode().IsDir(): - klog.ErrorS(nil, "Provided manifest path is a directory, not recursing into manifest path", "path", path) + klog.ErrorS( + nil, + "Provided manifest path is a directory, not recursing into manifest path", + "path", + path, + ) case statInfo.Mode().IsRegular(): pod, err := s.extractFromFile(path) if err != nil { @@ -181,7 +196,14 @@ func (s *sourceFile) extractFromDir(name string) ([]*v1.Pod, error) { pods = append(pods, pod) } default: - klog.ErrorS(nil, "Manifest path is not a directory or file", "path", path, "mode", statInfo.Mode()) + klog.ErrorS( + nil, + "Manifest path is not a directory or file", + "path", + path, + "mode", + statInfo.Mode(), + ) } } return pods, nil @@ -224,7 +246,11 @@ func (s *sourceFile) extractFromFile(filename string) (pod *v1.Pod, err error) { return pod, nil } - return pod, fmt.Errorf("%v: couldn't parse as pod(%v), please check config file", filename, podErr) + return pod, fmt.Errorf( + "%v: couldn't parse as pod(%v), please check config file", + filename, + podErr, + ) } func (s *sourceFile) replaceStore(pods ...*v1.Pod) (err error) { From c47a517c5bd0717ec22f95570237abc23cb44f62 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Tue, 23 Apr 2024 08:58:16 -0300 Subject: [PATCH 4/9] Revert "add: information about endpoint connection when auth handshake fails" This reverts commit 08f7312ab2024018b23d8d1b9a761cfe1027a35e. --- .../google.golang.org/grpc/internal/transport/http2_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 43f80aa5c0f..3c63c706986 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -286,7 +286,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts if transportCreds != nil { conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn) if err != nil { - return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed for %s: %v", addr.ServerName, err) + return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err) } for _, cd := range perRPCCreds { if cd.RequireTransportSecurity() { From 6dccf759f7238d1a8915dc929e977f1924aed028 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 22:11:39 +0200 Subject: [PATCH 5/9] Reverted Formatting --- pkg/kubelet/config/file.go | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/pkg/kubelet/config/file.go b/pkg/kubelet/config/file.go index 670804658e8..20237b21bd4 100644 --- a/pkg/kubelet/config/file.go +++ b/pkg/kubelet/config/file.go @@ -51,12 +51,7 @@ type sourceFile struct { } // NewSourceFile watches a config file for changes. -func NewSourceFile( - path string, - nodeName types.NodeName, - period time.Duration, - updates chan<- interface{}, -) { +func NewSourceFile(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) { // "github.com/sigma/go-inotify" requires a path without trailing "/" path = strings.TrimRight(path, string(os.PathSeparator)) @@ -65,12 +60,7 @@ func NewSourceFile( config.run() } -func newSourceFile( - path string, - nodeName types.NodeName, - period time.Duration, - updates chan<- interface{}, -) *sourceFile { +func newSourceFile(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) *sourceFile { send := func(objs []interface{}) { var pods []*v1.Pod for _, o := range objs { @@ -180,12 +170,7 @@ func (s *sourceFile) extractFromDir(name string) ([]*v1.Pod, error) { switch { case statInfo.Mode().IsDir(): - klog.ErrorS( - nil, - "Provided manifest path is a directory, not recursing into manifest path", - "path", - path, - ) + klog.ErrorS(nil, "Provided manifest path is a directory, not recursing into manifest path", "path", path) case statInfo.Mode().IsRegular(): pod, err := s.extractFromFile(path) if err != nil { @@ -196,14 +181,7 @@ func (s *sourceFile) extractFromDir(name string) ([]*v1.Pod, error) { pods = append(pods, pod) } default: - klog.ErrorS( - nil, - "Manifest path is not a directory or file", - "path", - path, - "mode", - statInfo.Mode(), - ) + klog.ErrorS(nil, "Manifest path is not a directory or file", "path", path, "mode", statInfo.Mode()) } } return pods, nil @@ -246,11 +224,7 @@ func (s *sourceFile) extractFromFile(filename string) (pod *v1.Pod, err error) { return pod, nil } - return pod, fmt.Errorf( - "%v: couldn't parse as pod(%v), please check config file", - filename, - podErr, - ) + return pod, fmt.Errorf("%v: couldn't parse as pod(%v), please check config file", filename, podErr) } func (s *sourceFile) replaceStore(pods ...*v1.Pod) (err error) { From 0d46f104e13d252042c4aa5a588ccabff1945977 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 22:29:12 +0200 Subject: [PATCH 6/9] Changed Formatting back to porject standard --- pkg/kubelet/config/flags.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/kubelet/config/flags.go b/pkg/kubelet/config/flags.go index 648eeb1d6b6..4ff13cacf0a 100644 --- a/pkg/kubelet/config/flags.go +++ b/pkg/kubelet/config/flags.go @@ -17,6 +17,8 @@ limitations under the License. package config import ( + "fmt" + "github.com/spf13/pflag" ) @@ -52,16 +54,6 @@ func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) { _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") // Image credential provider settings. - fs.StringVar( - &s.ImageCredentialProviderConfigFile, - "image-credential-provider-config", - s.ImageCredentialProviderConfigFile, - "The path to the credential provider plugin config file.", - ) - fs.StringVar( - &s.ImageCredentialProviderBinDir, - "image-credential-provider-bin-dir", - s.ImageCredentialProviderBinDir, - "The path to the directory where credential provider plugin binaries are located.", - ) + fs.StringVar(&s.ImageCredentialProviderConfigFile, "image-credential-provider-config", s.ImageCredentialProviderConfigFile, "The path to the credential provider plugin config file.") + fs.StringVar(&s.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", s.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.") } From 3f7c2286e3398c1b0bf8f3967e5bb3e1b151be24 Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 22:47:17 +0200 Subject: [PATCH 7/9] Reverted change: types and const removed --- pkg/kubelet/config/file.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/config/file.go b/pkg/kubelet/config/file.go index 20237b21bd4..79e2af6ed62 100644 --- a/pkg/kubelet/config/file.go +++ b/pkg/kubelet/config/file.go @@ -34,11 +34,20 @@ import ( utilio "k8s.io/utils/io" ) +type podEventType int + const ( + podAdd podEventType = iota + podModify + podDelete + eventBufferLen = 10 ) -type watchEvent struct{} +type watchEvent struct { + fileName string + eventType podEventType +} type sourceFile struct { path string From e71b5c0679a97a251d386bf2eb9a9e598371487a Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 22:50:43 +0200 Subject: [PATCH 8/9] Removed unnecessary use of fmt.Sprintf --- pkg/kubelet/config/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/config/flags.go b/pkg/kubelet/config/flags.go index 4ff13cacf0a..e493a28d071 100644 --- a/pkg/kubelet/config/flags.go +++ b/pkg/kubelet/config/flags.go @@ -50,7 +50,7 @@ type ContainerRuntimeOptions struct { func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) { // General settings. fs.StringVar(&s.RuntimeCgroups, "runtime-cgroups", s.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.") - fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprintf("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.")) + fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprint("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.")) _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") // Image credential provider settings. From f1e1f59c219c5f716f40c227c37f9cc91818e1ff Mon Sep 17 00:00:00 2001 From: Nils Carstensen Date: Sat, 24 Aug 2024 23:41:02 +0200 Subject: [PATCH 9/9] Revert "Removed unnecessary use of fmt.Sprintf" This reverts commit e71b5c0679a97a251d386bf2eb9a9e598371487a. --- pkg/kubelet/config/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/config/flags.go b/pkg/kubelet/config/flags.go index e493a28d071..4ff13cacf0a 100644 --- a/pkg/kubelet/config/flags.go +++ b/pkg/kubelet/config/flags.go @@ -50,7 +50,7 @@ type ContainerRuntimeOptions struct { func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) { // General settings. fs.StringVar(&s.RuntimeCgroups, "runtime-cgroups", s.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.") - fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprint("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.")) + fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprintf("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.")) _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") // Image credential provider settings.