Skip to content

Commit 4ab59db

Browse files
committed
cmd: log parameters on startup
cosmetic only change: log the computed parameters at startup to make troubleshooting a tad easier. Signed-off-by: Francesco Romani <[email protected]>
1 parent 672e8e6 commit 4ab59db

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cmd/main.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"fmt"
2525
"os"
2626
"runtime"
27+
"strconv"
28+
"strings"
2729
"time"
2830

2931
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -138,6 +140,16 @@ func (pa *Params) SetDefaults() {
138140
pa.enableLeaderElection = defaultEnableLeaderElection
139141
}
140142

143+
func (pa *Params) Summarize() string {
144+
var sb strings.Builder
145+
sb.WriteString("leaderElection=" + strconv.FormatBool(pa.enableLeaderElection))
146+
sb.WriteString(" scheduler=" + strconv.FormatBool(pa.enableScheduler))
147+
sb.WriteString(" webhooks=" + strconv.FormatBool(pa.enableWebhooks))
148+
sb.WriteString(" webhooksHTTP2=" + strconv.FormatBool(pa.enableHTTP2))
149+
sb.WriteString(" metrics=" + strconv.FormatBool(pa.enableMetrics))
150+
return sb.String()
151+
}
152+
141153
func (pa *Params) FromFlags() {
142154
flag.StringVar(&pa.metricsAddr, "metrics-bind-address", pa.metricsAddr, "The address the metric endpoint binds to.")
143155
flag.StringVar(&pa.probeAddr, "health-probe-bind-address", pa.probeAddr, "The address the probe endpoint binds to.")
@@ -195,7 +207,9 @@ func main() {
195207
config := textlogger.NewConfig(textlogger.Verbosity(int(klogV)))
196208
ctrl.SetLogger(textlogger.NewLogger(config))
197209

198-
klog.InfoS("starting", "program", version.OperatorProgramName(), "version", bi.Version, "branch", bi.Branch, "gitcommit", bi.Commit, "golang", runtime.Version(), "vl", klogV, "auxv", config.Verbosity().String())
210+
klog.InfoS("starting", "program", version.OperatorProgramName(), "version", bi.Version, "branch", bi.Branch, "gitcommit", bi.Commit, "golang", runtime.Version())
211+
klog.InfoS("starting", "program", version.OperatorProgramName(), "logVerbosity", klogV, "auxVerbosity", config.Verbosity().String())
212+
klog.InfoS("starting", "program", version.OperatorProgramName(), "params", params.Summarize())
199213

200214
ctx := context.Background()
201215

0 commit comments

Comments
 (0)