From 5ce9c107ad6aca0edf5273db941b8d82d7c925c7 Mon Sep 17 00:00:00 2001
From: Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
Date: Wed, 26 Apr 2017 11:49:42 +0100
Subject: [PATCH] Reduce init restart/kill times

The systemd unit 'TimeoutSec' value which controls the time
between sending a SIGTERM signal and a SIGKILL signal when
stopping or restarting the service has been reduced from 300
seconds to 120 seconds. This provides 2 minutes for long-lived
sessions to drain while preventing new ones from starting
before a restart or a stop.

The 'RestartSec' value which controls the time between the
service stop and start when restarting has been reduced from
150 seconds to 2 seconds to make the restart happen faster.

These values can be adjusted by using the *_init_config_overrides
variables which use the config_template task to change template
defaults.

Change-Id: Id721b89bd37df91192f48743ea3c32a305022a9f
---
 ...c_init_time_settings-1ef46f6b9d4fc1df.yaml | 23 +++++++++++++++++++
 templates/ironic-systemd-init.j2              |  4 ++--
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/ironic_init_time_settings-1ef46f6b9d4fc1df.yaml

diff --git a/releasenotes/notes/ironic_init_time_settings-1ef46f6b9d4fc1df.yaml b/releasenotes/notes/ironic_init_time_settings-1ef46f6b9d4fc1df.yaml
new file mode 100644
index 00000000..456d7f25
--- /dev/null
+++ b/releasenotes/notes/ironic_init_time_settings-1ef46f6b9d4fc1df.yaml
@@ -0,0 +1,23 @@
+---
+features:
+  - For the ``os_ironic`` role, the systemd unit ``TimeoutSec`` value which
+    controls the time between sending a SIGTERM signal and a SIGKILL signal
+    when stopping or restarting the service has been reduced from 300 seconds
+    to 120 seconds. This provides 2 minutes for long-lived sessions to drain
+    while preventing new ones from starting before a restart or a stop. The
+    ``RestartSec`` value which controls the time between the service stop and
+    start when restarting has been reduced from 150 seconds to 2 seconds to
+    make the restart happen faster. These values can be adjusted by using the
+    ``ironic_*_init_config_overrides`` variables which use the
+    ``config_template`` task to change template defaults.
+upgrade:
+  - For the ``os_ironic`` role, the systemd unit ``TimeoutSec`` value which
+    controls the time between sending a SIGTERM signal and a SIGKILL signal
+    when stopping or restarting the service has been reduced from 300 seconds
+    to 120 seconds. This provides 2 minutes for long-lived sessions to drain
+    while preventing new ones from starting before a restart or a stop. The
+    ``RestartSec`` value which controls the time between the service stop and
+    start when restarting has been reduced from 150 seconds to 2 seconds to
+    make the restart happen faster. These values can be adjusted by using the
+    ``ironic_*_init_config_overrides`` variables which use the
+    ``config_template`` task to change template defaults.
diff --git a/templates/ironic-systemd-init.j2 b/templates/ironic-systemd-init.j2
index f747db43..3bb5d30f 100644
--- a/templates/ironic-systemd-init.j2
+++ b/templates/ironic-systemd-init.j2
@@ -17,9 +17,9 @@ ExecStart={{ ironic_bin }}/{{ program_name }} {{ program_config_options|default(
 {% endif %}
 
 # Give a reasonable amount of time for the server to start up/shut down
-TimeoutSec=300
+TimeoutSec=120
 Restart=on-failure
-RestartSec=150
+RestartSec=2
 
 # This creates a specific slice which all services will operate from
 #  The accounting options give us the ability to see resource usage through