diff --git a/cmd/kubelet/app/plugins_providers.go b/cmd/kubelet/app/plugins_providers.go index bd71645de23..a3aecf140f8 100644 --- a/cmd/kubelet/app/plugins_providers.go +++ b/cmd/kubelet/app/plugins_providers.go @@ -43,16 +43,16 @@ func appendPluginBasedOnFeatureFlags(plugins []volume.VolumePlugin, inTreePlugin migrationComplete, err := csimigration.CheckMigrationFeatureFlags(featureGate, pluginInfo.pluginMigrationFeature, pluginInfo.pluginMigrationCompleteFeature, pluginInfo.pluginUnregisterFeature) if err != nil { - klog.Warningf("Unexpected CSI Migration Feature Flags combination detected: %v. CSI Migration may not take effect", err) + klog.InfoS("Unexpected CSI Migration Feature Flags combination detected, CSI Migration may not take effect", "err", err) // TODO: fail and return here once alpha only tests can set the feature flags for a plugin correctly } // TODO: This can be removed after feature flag CSIMigrationvSphereComplete is removed. if migrationComplete { - klog.Infof("Skip registration of plugin %s since migration is complete", inTreePluginName) + klog.InfoS("Skipped registration of plugin since migration is completed", "pluginName", inTreePluginName) return plugins, nil } if featureGate.Enabled(pluginInfo.pluginUnregisterFeature) { - klog.Infof("Skip registration of plugin %s since feature flag %v is enabled", inTreePluginName, pluginInfo.pluginUnregisterFeature) + klog.Infof("Skipped registration of plugin since feature flag is enabled", "pluginName", inTreePluginName, "featureFlag", pluginInfo.pluginUnregisterFeature) return plugins, nil } diff --git a/cmd/kubelet/app/server_linux.go b/cmd/kubelet/app/server_linux.go index f6cff9af261..c22e24d5312 100644 --- a/cmd/kubelet/app/server_linux.go +++ b/cmd/kubelet/app/server_linux.go @@ -24,19 +24,19 @@ import ( func watchForLockfileContention(path string, done chan struct{}) error { watcher, err := inotify.NewWatcher() if err != nil { - klog.Errorf("unable to create watcher for lockfile: %v", err) + klog.ErrorS(err, "Unable to create watcher for lockfile") return err } if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil { - klog.Errorf("unable to watch lockfile: %v", err) + klog.ErrorS(err, "Unable to watch lockfile") return err } go func() { select { case ev := <-watcher.Event: - klog.Infof("inotify event: %v", ev) + klog.InfoS("inotify event", "event", ev) case err = <-watcher.Error: - klog.Errorf("inotify watcher error: %v", err) + klog.ErrorS(err, "inotify watcher error") } close(done) }() diff --git a/pkg/kubelet/cadvisor/cadvisor_linux.go b/pkg/kubelet/cadvisor/cadvisor_linux.go index 0c701cb98d3..309b4efe7c9 100644 --- a/pkg/kubelet/cadvisor/cadvisor_linux.go +++ b/pkg/kubelet/cadvisor/cadvisor_linux.go @@ -79,7 +79,7 @@ func init() { f.DefValue = defaultValue f.Value.Set(defaultValue) } else { - klog.Errorf("Expected cAdvisor flag %q not found", name) + klog.ErrorS(nil, "Expected cAdvisor flag not found", "flag", name) } } } @@ -186,7 +186,7 @@ func (cc *cadvisorClient) getFsInfo(label string) (cadvisorapiv2.FsInfo, error) } // TODO(vmarmol): Handle this better when a label has more than one image filesystem. if len(res) > 1 { - klog.Warningf("More than one filesystem labeled %q: %#v. Only using the first one", label, res) + klog.InfoS("More than one filesystem labeled. Only using the first one", "label", label, "fileSystem", res) } return res[0], nil diff --git a/pkg/kubelet/cri/remote/util/util_unix.go b/pkg/kubelet/cri/remote/util/util_unix.go index ef067bd4c46..e5e2d7bedea 100644 --- a/pkg/kubelet/cri/remote/util/util_unix.go +++ b/pkg/kubelet/cri/remote/util/util_unix.go @@ -100,7 +100,7 @@ func parseEndpointWithFallbackProtocol(endpoint string, fallbackProtocol string) fallbackEndpoint := fallbackProtocol + "://" + endpoint protocol, addr, err = parseEndpoint(fallbackEndpoint) if err == nil { - klog.Warningf("Using %q as endpoint is deprecated, please consider using full url format %q.", endpoint, fallbackEndpoint) + klog.InfoS("Using this format as endpoint is deprecated, please consider using full url format.", "deprecatedFormat", endpoint, "fullURLFormat", fallbackEndpoint) } } return diff --git a/pkg/kubelet/images/image_manager.go b/pkg/kubelet/images/image_manager.go index d41ebcebc38..6d8b5f33429 100644 --- a/pkg/kubelet/images/image_manager.go +++ b/pkg/kubelet/images/image_manager.go @@ -90,7 +90,7 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p logPrefix := fmt.Sprintf("%s/%s/%s", pod.Namespace, pod.Name, container.Image) ref, err := kubecontainer.GenerateContainerRef(pod, container) if err != nil { - klog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err) + klog.ErrorS(err, "Couldn't make a ref to pod", "pod", klog.KObj(pod), "containerName", container.Name) } // If the image contains no tag or digest, a default tag should be applied.