We weren't catching SIGTERM and cancelling our context, so the go
runtime would have us exit with a non-zero code when the signal was
received. Let's catch it and try to exit gracefully.
i.e. before:
(...)
I0508 11:08:00.426917 1787442 log_monitor.go:237] Initialize condition generated: []
^C
$ echo $?
130
and now:
(...)
I0508 11:07:42.150562 1787146 log_monitor.go:237] Initialize condition generated: []
^C
I0508 11:07:43.372093 1787146 log_monitor.go:123] Stop log monitor /tmp/npd-test.json
I0508 11:07:43.652876 1787146 log_watcher.go:104] Stop watching filelog
I0508 11:07:43.652923 1787146 log_monitor.go:144] Log monitor stopped: /tmp/npd-test.json
$ echo $?
0
The Unix entrypoint already sets legacy_stderr_threshold_behavior=false
and stderrthreshold=INFO, but the Windows entrypoint was missed.
klog v2 defaults -logtostderr to true. When active, -stderrthreshold is
silently ignored — all log levels are unconditionally sent to stderr.
Setting legacy_stderr_threshold_behavior=false enables the fix so that
-stderrthreshold is honored even when -logtostderr=true.
Ref: kubernetes/klog#212, kubernetes/klog#432
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>