Structured Logging migration: modify logs of kube-scheduler

This commit is contained in:
卢振兴10069964 2021-04-07 15:53:06 +08:00
parent b0abe89ae2
commit 98a03ae57b
2 changed files with 3 additions and 3 deletions

View File

@ -69,7 +69,7 @@ func LogOrWriteConfig(fileName string, cfg *kubeschedulerconfig.KubeSchedulerCon
return err return err
} }
configString := string(bytes) configString := string(bytes)
klog.Infof("Using component config:\n%+v\n", configString) klog.InfoS("Using component config", "config", configString)
} }
if len(fileName) > 0 { if len(fileName) > 0 {
@ -81,7 +81,7 @@ func LogOrWriteConfig(fileName string, cfg *kubeschedulerconfig.KubeSchedulerCon
if err := encoder.Encode(cfg, configFile); err != nil { if err := encoder.Encode(cfg, configFile); err != nil {
return err return err
} }
klog.Infof("Wrote configuration to: %s\n", fileName) klog.InfoS("Wrote configuration", "file", fileName)
os.Exit(0) os.Exit(0)
} }
return nil return nil

View File

@ -135,7 +135,7 @@ func runCommand(cmd *cobra.Command, opts *options.Options, registryOptions ...Op
// Run executes the scheduler based on the given configuration. It only returns on error or when context is done. // Run executes the scheduler based on the given configuration. It only returns on error or when context is done.
func Run(ctx context.Context, cc *schedulerserverconfig.CompletedConfig, sched *scheduler.Scheduler) error { func Run(ctx context.Context, cc *schedulerserverconfig.CompletedConfig, sched *scheduler.Scheduler) error {
// To help debugging, immediately log version // To help debugging, immediately log version
klog.V(1).Infof("Starting Kubernetes Scheduler version %+v", version.Get()) klog.V(1).InfoS("Starting Kubernetes Scheduler version", "version", version.Get())
// Configz registration. // Configz registration.
if cz, err := configz.New("componentconfig"); err == nil { if cz, err := configz.New("componentconfig"); err == nil {