service: add 'debug' option to RestartMode=
One of the major pait points of managing fleets of headless nodes is that when something fails at startup, unless debug level was already enabled (which usually isn't, as it's a firehose), one needs to manually enable it and pray the issue can be reproduced, which often is really hard and time consuming, just to get extra info. Usually the extra log messages are enough to triage an issue. This new option makes it so that when a service fails and is restarted due to Restart=, log level for that unit is set to debug, so that all setup code in pid1 and sd-executor logs at debug level, and also a new DEBUG_INVOCATION=1 env var is passed to the service itself, so that it knows it should start with a higher log level. Once the unit succeeds or reaches the rate limit the original level is restored.
This commit is contained in:
committed by
Luca Boccassi
parent
23e3bddc48
commit
7d8bbfbe08
@@ -4107,7 +4107,9 @@ int exec_invoke(
|
||||
|
||||
/* This should be mostly redundant, as the log level is also passed as an argument of the executor,
|
||||
* and is already applied earlier. Just for safety. */
|
||||
if (context->log_level_max >= 0)
|
||||
if (params->debug_invocation)
|
||||
log_set_max_level(LOG_PRI(LOG_DEBUG));
|
||||
else if (context->log_level_max >= 0)
|
||||
log_set_max_level(context->log_level_max);
|
||||
|
||||
/* Explicitly test for CVE-2021-4034 inspired invocations */
|
||||
|
||||
Reference in New Issue
Block a user