Skip to content

Commit

Permalink
Remove settings of logtostderr flag value
Browse files Browse the repository at this point in the history
  • Loading branch information
bells17 committed Aug 17, 2023
1 parent 51def39 commit 9a9aef5
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions cmd/livenessprobe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,11 @@ func acquireConnection(ctx context.Context, metricsManager metrics.CSIMetricsMan
}

func main() {
// We run `klog.InitFlags` to configure the `logtostderr` option.
// Due to a conflict with `logsapi.AddGoFlags`, we set only
// the `logtostderr` option in `flag.CommandLine` using the `fs` variable
// to avoid errors.
//
// For options set by klog and component-base logs, see the links below:
// https://github.com/kubernetes/component-base/blob/v0.28.0-rc.0/logs/api/v1/options.go#L337-L355
// https://github.com/kubernetes/klog/blob/v2.100.1/klog.go#L400-L424
var fs flag.FlagSet
klog.InitFlags(&fs)
fs.VisitAll(func(f *flag.Flag) {
switch f.Name {
case "logtostderr":
flag.CommandLine.Var(f.Value, f.Name, f.Usage)
}
})
fg := featuregate.NewFeatureGate()
logsapi.AddFeatureGates(fg)
c := logsapi.NewLoggingConfiguration()
logsapi.AddGoFlags(c, flag.CommandLine)
logs.InitLogs()
flag.Set("logtostderr", "true")
flag.Parse()
if err := logsapi.ValidateAndApply(c, fg); err != nil {
klog.ErrorS(err, "LoggingConfiguration is invalid")
Expand Down

0 comments on commit 9a9aef5

Please sign in to comment.