Proposal: Use Signal to dynamically modify log levels or enable pprof

78 views
Skip to first unread message

Aimuz

unread,
Dec 8, 2022, 6:01:35 AM12/8/22
to dev
A premature proposal

Switching Log Levels via Signal

kill -SIGUSR1 pid

Each time it is executed, the log level will be adjusted to one level up to the maximum value, and then back to the minimum value


kill -SIGUSR2 pid

Each execution will toggle between pprof enabled and pprof disabled states. Or pprof will be written to a file.

This proposal may be helpful in troubleshooting problems, avoiding program restarts and maximizing the availability of information on site.

Aimuz

unread,
Dec 8, 2022, 6:06:19 AM12/8/22
to dev, Aimuz

Aldo Culquicondor

unread,
Dec 8, 2022, 11:00:25 AM12/8/22
to mr....@gmail.com, dev
Are you targeting a specific binary or do you want to target all k8s binaries?

Note that kube-scheduler already responds to SIGUSR2 to print a dump of its cache into the log.

We have an HTTP endpoint for all binaries that you can use to grab a pprof (kube-scheduler code). It's not expensive to keep that endpoint up all the time.

The ability to increase the log level at runtime sounds desirable to me.

Aldo


--
You received this message because you are subscribed to the Google Groups "dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dev+uns...@kubernetes.io.
To view this discussion on the web visit https://groups.google.com/a/kubernetes.io/d/msgid/dev/ced8a41d-443e-4e29-96c3-421486c57dc1n%40kubernetes.io.

Bowei Du

unread,
Dec 8, 2022, 11:54:52 AM12/8/22
to aco...@google.com, mr....@gmail.com, dev
Use of signals is usually not preferred vs a standard HTTP flag changing endpoint:

- Does not allow for passing additional information or extension/change later on.
- May already be used for other purposes.

Thanks,
Bowei

Antoine Pelisse

unread,
Dec 8, 2022, 12:06:26 PM12/8/22
to bo...@google.com, aco...@google.com, mr....@gmail.com, dev
Aimuz, why don't you keep the http profile endpoint open all the time?
If you think that might be a security concern, then you might be interested in that change: 

Thanks,
Antoine


Aimuz

unread,
Dec 8, 2022, 8:52:29 PM12/8/22
to dev, apel...@google.com, aco...@google.com, Aimuz, dev, bo...@google.com
I'd like to add to all the binaries and then leave the feature on without changing the configuration, so that I can avoid problems that can't be tracked after a reboot. If you can get pprof to turn on by default is one way

Rebooting would solve 90% of the problem.

So does adjusting the log format.

As for security, I didn't consider it.

If kube-scheduler already uses SIGUSR2, can we add SIGUSR1 to all binaries to adjust the log output level? He would be really useful.

Thanks!
Aimuz

Antoine Pelisse

unread,
Dec 8, 2022, 11:26:50 PM12/8/22
to Aimuz, dev, aco...@google.com, bo...@google.com
I think you can adjust the log-level through the debug endpoint too (when profiling is enabled)

I haven't tried that though.
Reply all
Reply to author
Forward
0 new messages