core: split system/user job timeouts and make them configurable

Config options are -Ddefault-timeout-sec= and -Ddefault-user-timeout-sec=.
Existing -Dupdate-helper-user-timeout= is renamed to -Dupdate-helper-user-timeout-sec=
for consistency. All three options take an integer value in seconds. The
renaming and type-change of the option is a small compat break, but it's just
at compile time and result in a clear error message. I also doubt that anyone was
actually using the option.

This commit separates the user manager timeouts, but keeps them unchanged at 90 s.
The timeout for the user manager is set to 4/3*user-timeout, which means that it
is still 120 s.

Fedora wants to experiment with lower timeouts, but doing this via a patch would
be annoying and more work than necessary. Let's make this easy to configure.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-02-01 11:52:29 +00:00
committed by Luca Boccassi
parent 15796f28ea
commit e4c7b5f517
13 changed files with 62 additions and 46 deletions
+6 -1
View File
@@ -25,8 +25,13 @@
# endif
#endif
#define DEFAULT_TIMEOUT_USEC (90*USEC_PER_SEC)
#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
/* Many different things, but also system unit start/stop */
#define DEFAULT_TIMEOUT_USEC (DEFAULT_TIMEOUT_SEC*USEC_PER_SEC)
/* User unit start/stop */
#define DEFAULT_USER_TIMEOUT_USEC (DEFAULT_USER_TIMEOUT_SEC*USEC_PER_SEC)
/* Timeout for user confirmation on the console */
#define DEFAULT_CONFIRM_USEC (30*USEC_PER_SEC)
/* We use an extra-long timeout for the reload. This is because a reload or reexec means generators are rerun
+4 -4
View File
@@ -2436,11 +2436,11 @@ static void reset_arguments(void) {
arg_default_std_output = EXEC_OUTPUT_JOURNAL;
arg_default_std_error = EXEC_OUTPUT_INHERIT;
arg_default_restart_usec = DEFAULT_RESTART_USEC;
arg_default_timeout_start_usec = DEFAULT_TIMEOUT_USEC;
arg_default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
arg_default_timeout_abort_usec = DEFAULT_TIMEOUT_USEC;
arg_default_timeout_start_usec = manager_default_timeout(arg_system);
arg_default_timeout_stop_usec = manager_default_timeout(arg_system);
arg_default_timeout_abort_usec = manager_default_timeout(arg_system);
arg_default_timeout_abort_set = false;
arg_default_device_timeout_usec = DEFAULT_TIMEOUT_USEC;
arg_default_device_timeout_usec = manager_default_timeout(arg_system);
arg_default_start_limit_interval = DEFAULT_START_LIMIT_INTERVAL;
arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
arg_runtime_watchdog = 0;
+3 -3
View File
@@ -835,10 +835,10 @@ int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager *
.default_memory_accounting = MEMORY_ACCOUNTING_DEFAULT,
.default_tasks_accounting = true,
.default_tasks_max = TASKS_MAX_UNSET,
.default_timeout_start_usec = DEFAULT_TIMEOUT_USEC,
.default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC,
.default_timeout_start_usec = manager_default_timeout(scope == LOOKUP_SCOPE_SYSTEM),
.default_timeout_stop_usec = manager_default_timeout(scope == LOOKUP_SCOPE_SYSTEM),
.default_restart_usec = DEFAULT_RESTART_USEC,
.default_device_timeout_usec = DEFAULT_TIMEOUT_USEC,
.default_device_timeout_usec = manager_default_timeout(scope == LOOKUP_SCOPE_SYSTEM),
.original_log_level = -1,
.original_log_target = _LOG_TARGET_INVALID,
+4
View File
@@ -485,6 +485,10 @@ static inline usec_t manager_default_timeout_abort_usec(Manager *m) {
#define MANAGER_IS_TEST_RUN(m) ((m)->test_run_flags != 0)
static inline usec_t manager_default_timeout(bool is_system) {
return is_system ? DEFAULT_TIMEOUT_USEC : DEFAULT_USER_TIMEOUT_USEC;
}
int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager **m);
Manager* manager_free(Manager *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
+3 -3
View File
@@ -43,10 +43,10 @@
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=journal
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTimeoutStartSec={{DEFAULT_TIMEOUT_SEC}}s
#DefaultTimeoutStopSec={{DEFAULT_TIMEOUT_SEC}}s
#DefaultTimeoutAbortSec=
#DefaultDeviceTimeoutSec=90s
#DefaultDeviceTimeoutSec={{DEFAULT_TIMEOUT_SEC}}s
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
+3 -2
View File
@@ -24,9 +24,10 @@
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=inherit
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTimeoutStartSec={{DEFAULT_USER_TIMEOUT_SEC}}s
#DefaultTimeoutStopSec={{DEFAULT_USER_TIMEOUT_SEC}}s
#DefaultTimeoutAbortSec=
#DefaultDeviceTimeoutSec={{DEFAULT_USER_TIMEOUT_SEC}}s
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
+5 -5
View File
@@ -32,7 +32,7 @@ case "$command" in
users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p')
for user in $users; do
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT}} \
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
systemctl --user -M "$user@" disable --now --no-warn "$@" &
done
wait
@@ -53,7 +53,7 @@ case "$command" in
users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p')
for user in $users; do
for unit in "$@"; do
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT}} \
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
systemctl --user -M "$user@" set-property "$unit" Markers=+needs-restart &
done
done
@@ -89,7 +89,7 @@ case "$command" in
if [[ "$command" =~ reexec ]]; then
for user in $users; do
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT}} \
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
systemctl --user -M "$user@" daemon-reexec &
done
wait
@@ -97,7 +97,7 @@ case "$command" in
if [[ "$command" =~ reload ]]; then
for user in $users; do
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT}} \
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
systemctl --user -M "$user@" daemon-reload &
done
wait
@@ -105,7 +105,7 @@ case "$command" in
if [[ "$command" =~ restart ]]; then
for user in $users; do
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT}} \
SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \
systemctl --user -M "$user@" reload-or-restart --marked &
done
wait