From 33da8fc8eb7a5347ecef962ce20c5a05926bb927 Mon Sep 17 00:00:00 2001
From: Kevin Carter <kevin.carter@rackspace.com>
Date: Tue, 28 Mar 2017 23:58:42 -0500
Subject: [PATCH] Ensure the components are isolated from the system

This creates a specific slice which all OpenStack services will operate
from. By creating an independent slice these components will be governed
away from the system slice allowing us to better optimise resource
consumption.

See the following for more information on slices:

* https://www.freedesktop.org/software/systemd/man/systemd.slice.html

See for following for more information on resource controls:

* https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html

Tools like ``systemd-cgtop`` and ``systemd-cgls`` will now give us
insight into specific processes, process groups, and resouce consumption
in ways that we've not had access to before. To enable some of this reporting
the accounting options have been added to the [Service] section of the unit
file.

Change-Id: Ife2e28ce6b3e0d0219b8a5ec2ca8d9dbe513d5a7
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
---
 cluster_metrics/templates/influxdbrelay.service.j2 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/cluster_metrics/templates/influxdbrelay.service.j2 b/cluster_metrics/templates/influxdbrelay.service.j2
index 5c9512bd..edea86fc 100644
--- a/cluster_metrics/templates/influxdbrelay.service.j2
+++ b/cluster_metrics/templates/influxdbrelay.service.j2
@@ -12,6 +12,20 @@ ExecStart=/opt/influxdb-relay/bin/influxdb-relay -config /opt/influxdb-relay/rel
 KillMode=control-group
 Restart=on-failure
 
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+Restart=on-failure
+RestartSec=150
+
+# This creates a specific slice which all services will operate from
+#  The accounting options give us the ability to see resource usage through
+#  the `systemd-cgtop` command.
+Slice=influxdbrelay.slice
+CPUAccounting=true
+BlockIOAccounting=true
+MemoryAccounting=false
+TasksAccounting=true
+
 [Install]
 WantedBy=multi-user.target
 Alias=influxd.service