Blob Blame History Raw
From e4b03ea015061d4bb01ea734e04946924c577032 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 28 Oct 2014 01:42:13 +0100
Subject: [PATCH] core: remove system start timeout logic again

The system start timeout as previously implemented would get confused by
long-running services that are included in the initial system startup
transaction for example by being cron-job-like long-running services
triggered immediately at boot. Such long-running jobs would be subject
to the default 15min timeout, esily triggering it.

Hence, remove this again. In a subsequent commit, introduce per-target
job timeouts instead, that allow us to control these timeouts more
finegrained.

(cherry picked from commit fa1b91632c5220e6589007af4cd573ca909f915a)

Conflicts:
	NEWS
	src/core/main.c
---
 NEWS                        |  6 ------
 man/systemd-system.conf.xml | 26 --------------------------
 src/core/main.c             | 12 ------------
 src/core/manager.c          | 37 -------------------------------------
 src/core/manager.h          |  8 --------
 src/core/system.conf        |  3 ---
 6 files changed, 92 deletions(-)

diff --git a/NEWS b/NEWS
index 6d93787bf8..597e7f962b 100644
--- a/NEWS
+++ b/NEWS
@@ -22,12 +22,6 @@ CHANGES WITH 217:
           /run/systemd/user directory that was already previously
           supported, but is under the control of the user.
 
-        * A timeout for the start of the system can be configured. The
-          system can be configured to reboot or poweroff if the basic
-          system default target is not reached before the timeout (new
-          StartTimeoutSec=, StartTimeoutAction=,
-          StartTimeoutRebootArgument= options).
-
         * systemd-logind can be configured to also handle lid switch
           events even when the machine is docked or multiple displays
           are attached (HandleLidSwitchDocked= option).
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 1fad1dba80..284516d931 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -280,32 +280,6 @@
                         </varlistentry>
 
                         <varlistentry>
-                                <term><varname>StartTimeoutSec=</varname></term>
-                                <term><varname>StartTimeoutAction=</varname></term>
-                                <term><varname>StartTimeoutRebootArgument=</varname></term>
-
-                                <listitem><para>Configures an over-all
-                                system start-up timeout and controls
-                                what to do when the timeout is
-                                reached. <varname>StartTimeoutSec=</varname>
-                                specifies the timeout, and defaults to
-                                <literal>15min</literal>. <varname>StartTimeoutAction=</varname>
-                                configures the action to take when the
-                                system did not finish boot-up within
-                                the specified time. It takes the same
-                                values as the per-service
-                                <varname>StartLimitAction=</varname>
-                                setting, see
-                                <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-                                for details. Defaults to
-                                <option>poweroff-force</option>. <varname>StartTimeoutRebootArgument=</varname>
-                                configures an optional reboot string
-                                to pass to the
-                                <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
-                                system call.</para></listitem>
-                        </varlistentry>
-
-                        <varlistentry>
                                 <term><varname>DefaultTimerAccuracySec=</varname></term>
 
                                 <listitem><para>Sets the default
diff --git a/src/core/main.c b/src/core/main.c
index 0388f46c36..e75866ff7e 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -116,9 +116,6 @@ static FILE* arg_serialization = NULL;
 static bool arg_default_cpu_accounting = false;
 static bool arg_default_blockio_accounting = false;
 static bool arg_default_memory_accounting = false;
-static usec_t arg_start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
-static FailureAction arg_start_timeout_action = FAILURE_ACTION_POWEROFF_FORCE;
-static char *arg_start_timeout_reboot_arg = NULL;
 
 static void nop_handler(int sig) {}
 
@@ -673,9 +670,6 @@ static int parse_config_file(void) {
                 { "Manager", "DefaultCPUAccounting",      config_parse_bool,             0, &arg_default_cpu_accounting            },
                 { "Manager", "DefaultBlockIOAccounting",  config_parse_bool,             0, &arg_default_blockio_accounting        },
                 { "Manager", "DefaultMemoryAccounting",   config_parse_bool,             0, &arg_default_memory_accounting         },
-                { "Manager", "StartTimeoutSec",           config_parse_sec,              0, &arg_start_timeout_usec                },
-                { "Manager", "StartTimeoutAction",        config_parse_failure_action,   0, &arg_start_timeout_action              },
-                { "Manager", "StartTimeoutRebootArgument",config_parse_string,           0, &arg_start_timeout_reboot_arg          },
                 {}
         };
 
@@ -1635,9 +1629,6 @@ int main(int argc, char *argv[]) {
         m->default_memory_accounting = arg_default_memory_accounting;
         m->runtime_watchdog = arg_runtime_watchdog;
         m->shutdown_watchdog = arg_shutdown_watchdog;
-        m->start_timeout_usec = arg_start_timeout_usec;
-        m->start_timeout_action = arg_start_timeout_action;
-        free_and_strdup(&m->start_timeout_reboot_arg, arg_start_timeout_reboot_arg);
 
         m->userspace_timestamp = userspace_timestamp;
         m->kernel_timestamp = kernel_timestamp;
@@ -1827,9 +1818,6 @@ finish:
         set_free(arg_syscall_archs);
         arg_syscall_archs = NULL;
 
-        free(arg_start_timeout_reboot_arg);
-        arg_start_timeout_reboot_arg = NULL;
-
         label_finish();
 
         if (reexecute) {
diff --git a/src/core/manager.c b/src/core/manager.c
index 726977fcfc..cad1501417 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -435,8 +435,6 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
         m->running_as = running_as;
         m->exit_code = _MANAGER_EXIT_CODE_INVALID;
         m->default_timer_accuracy_usec = USEC_PER_MINUTE;
-        m->start_timeout_usec = DEFAULT_MANAGER_START_TIMEOUT_USEC;
-        m->start_timeout_action = FAILURE_ACTION_POWEROFF_FORCE;
 
         m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1;
 
@@ -839,9 +837,6 @@ void manager_free(Manager *m) {
 
         manager_close_idle_pipe(m);
 
-        sd_event_source_unref(m->start_timeout_event_source);
-        free(m->start_timeout_reboot_arg);
-
         udev_unref(m->udev);
         sd_event_unref(m->event);
 
@@ -989,20 +984,6 @@ static int manager_distribute_fds(Manager *m, FDSet *fds) {
         return 0;
 }
 
-static int on_start_timeout(sd_event_source *s, usec_t usec, void *userdata) {
-        Manager *m = userdata;
-
-        assert(s);
-        assert(m);
-
-        m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
-
-        log_error("Startup timed out.");
-
-        failure_action(m, m->start_timeout_action, m->start_timeout_reboot_arg);
-        return 0;
-}
-
 int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
         int r, q;
 
@@ -1075,22 +1056,6 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
                 m->send_reloading_done = true;
         }
 
-        /* Possibly set up a start timeout */
-        if (!dual_timestamp_is_set(&m->finish_timestamp)) {
-                m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
-
-                if (m->start_timeout_usec) {
-                        r = sd_event_add_time(
-                                        m->event,
-                                        &m->start_timeout_event_source,
-                                        CLOCK_MONOTONIC,
-                                        now(CLOCK_MONOTONIC) + m->start_timeout_usec, 0,
-                                        on_start_timeout, m);
-                        if (r < 0)
-                                log_error("Failed to add start timeout event: %s", strerror(-r));
-                }
-        }
-
         return r;
 }
 
@@ -2534,8 +2499,6 @@ void manager_check_finished(Manager *m) {
 
         dual_timestamp_get(&m->finish_timestamp);
 
-        m->start_timeout_event_source = sd_event_source_unref(m->start_timeout_event_source);
-
         if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) {
 
                 /* Note that m->kernel_usec.monotonic is always at 0,
diff --git a/src/core/manager.h b/src/core/manager.h
index 8e3c146b42..65821671e7 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -33,8 +33,6 @@
 /* Enforce upper limit how many names we allow */
 #define MANAGER_MAX_NAMES 131072 /* 128K */
 
-#define DEFAULT_MANAGER_START_TIMEOUT_USEC (15*USEC_PER_MINUTE)
-
 typedef struct Manager Manager;
 
 typedef enum ManagerState {
@@ -284,12 +282,6 @@ struct Manager {
 
         /* Used for processing polkit authorization responses */
         Hashmap *polkit_registry;
-
-        /* System wide startup timeouts */
-        usec_t start_timeout_usec;
-        sd_event_source *start_timeout_event_source;
-        FailureAction start_timeout_action;
-        char *start_timeout_reboot_arg;
 };
 
 int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m);
diff --git a/src/core/system.conf b/src/core/system.conf
index 5a723bb20e..65a35a0689 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -23,9 +23,6 @@
 #CapabilityBoundingSet=
 #SystemCallArchitectures=
 #TimerSlackNSec=
-#StartTimeoutSec=15min
-#StartTimeoutAction=poweroff-force
-#StartTimeoutRebootArgument=
 #DefaultTimerAccuracySec=1min
 #DefaultStandardOutput=journal
 #DefaultStandardError=inherit