From 61c00c340d7c9ae983b17bd692a9154cc3de6960 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 28 Mar 2017 19:41: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: I6dccb6eeabceea30922cbcf3a60e32e841612fd0 Signed-off-by: Kevin Carter (cherry picked from commit b6efe327aae5fbe0a4b12f7b1dbd5c17eeaf0cbf) --- defaults/main.yml | 4 ++++ .../trove-init-config-overrides-ffce7e419061c4da.yaml | 10 ++++++++++ tasks/trove_init.yml | 3 +++ tasks/trove_init_systemd.yml | 4 +++- templates/trove-systemd-init.j2 | 9 +++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/trove-init-config-overrides-ffce7e419061c4da.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 2738293..49351cd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -180,3 +180,7 @@ trove_conductor_config_overrides: {} trove_taskmanager_config_overrides: {} trove_guestagent_config_overrides: {} trove_policy_overrides: {} + +trove_api_init_config_overrides: {} +trove_conductor_init_config_overrides: {} +trove_taskmanager_init_config_overrides: {} diff --git a/releasenotes/notes/trove-init-config-overrides-ffce7e419061c4da.yaml b/releasenotes/notes/trove-init-config-overrides-ffce7e419061c4da.yaml new file mode 100644 index 0000000..0b84eb4 --- /dev/null +++ b/releasenotes/notes/trove-init-config-overrides-ffce7e419061c4da.yaml @@ -0,0 +1,10 @@ +--- +features: + - New variables have been added to allow a deployer to customize + a trove systemd unit file to their liking. + - The task dropping the trove systemd unit files now uses the + ``config_template`` action plugin allowing deployers access to + customize the unit files as they see fit without having to + load extra options into the defaults and polute the generic + systemd unit file with jinja2 variables and conditionals. + diff --git a/tasks/trove_init.yml b/tasks/trove_init.yml index 1d0680f..c080217 100644 --- a/tasks/trove_init.yml +++ b/tasks/trove_init.yml @@ -22,6 +22,7 @@ system_user: "{{ trove_system_user_name }}" system_group: "{{ trove_system_group_name }}" service_home: "{{ trove_system_user_home }}" + init_config_overrides: "{{ trove_api_init_config_overrides }}" when: inventory_hostname in groups['trove_api'] - include: trove_init_common.yml @@ -31,6 +32,7 @@ system_user: "{{ trove_system_user_name }}" system_group: "{{ trove_system_group_name }}" service_home: "{{ trove_system_user_home }}" + init_config_overrides: "{{ trove_conductor_init_config_overrides }}" when: inventory_hostname in groups['trove_conductor'] - include: trove_init_common.yml @@ -40,4 +42,5 @@ system_user: "{{ trove_system_user_name }}" system_group: "{{ trove_system_group_name }}" service_home: "{{ trove_system_user_home }}" + init_config_overrides: "{{ trove_taskmanager_init_config_overrides }}" when: inventory_hostname in groups['trove_taskmanager'] diff --git a/tasks/trove_init_systemd.yml b/tasks/trove_init_systemd.yml index fae3808..99e1a10 100644 --- a/tasks/trove_init_systemd.yml +++ b/tasks/trove_init_systemd.yml @@ -40,12 +40,14 @@ group: "root" - name: Place the systemd init script - template: + config_template: src: "trove-systemd-init.j2" dest: "/etc/systemd/system/{{ program_name }}.service" mode: "0644" owner: "root" group: "root" + config_overrides: "{{ init_config_overrides }}" + config_type: "ini" register: systemd_init - name: Reload the systemd daemon diff --git a/templates/trove-systemd-init.j2 b/templates/trove-systemd-init.j2 index 2919b0f..cf9bf3b 100644 --- a/templates/trove-systemd-init.j2 +++ b/templates/trove-systemd-init.j2 @@ -21,5 +21,14 @@ 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=trove.slice +CPUAccounting=true +BlockIOAccounting=true +MemoryAccounting=false +TasksAccounting=true + [Install] WantedBy=multi-user.target