From 8044b2c5e146147b3a1b47224119d9834ae0cb89 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 28 Mar 2017 23:41:02 -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: I2b5c6189a6eabbdb7854dcee97edf47ef03f8757 Signed-off-by: Kevin Carter (cherry picked from commit 9dcacb8fd6feef02e485f99c83535707ae67876b) --- defaults/main.yml | 7 +++++++ .../aodh-init-config-overrides-ffce7e419061c4da.yaml | 10 ++++++++++ tasks/aodh_init_systemd.yml | 4 +++- templates/aodh-systemd-init.j2 | 9 +++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/aodh-init-config-overrides-ffce7e419061c4da.yaml diff --git a/defaults/main.yml b/defaults/main.yml index f599ca2..2efe223 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -115,17 +115,24 @@ aodh_pip_packages: - PyMySQL - gnocchiclient +aodh_alarm_notifier_init_overrides: {} +aodh_alarm_evaluator_init_overrides: {} +aodh_listener_init_overrides: {} + ## Service Name-Group Mapping aodh_services: aodh-notifier: group: aodh_alarm_notifier service_name: aodh-notifier + init_config_overrides: "{{ aodh_alarm_notifier_init_overrides }}" aodh-evaluator: group: aodh_alarm_evaluator service_name: aodh-evaluator + init_config_overrides: "{{ aodh_alarm_evaluator_init_overrides }}" aodh-listener: group: aodh_listener service_name: aodh-listener + init_config_overrides: "{{ aodh_listener_init_overrides }}" aodh_required_secrets: - memcached_encryption_key diff --git a/releasenotes/notes/aodh-init-config-overrides-ffce7e419061c4da.yaml b/releasenotes/notes/aodh-init-config-overrides-ffce7e419061c4da.yaml new file mode 100644 index 0000000..dde0412 --- /dev/null +++ b/releasenotes/notes/aodh-init-config-overrides-ffce7e419061c4da.yaml @@ -0,0 +1,10 @@ +--- +features: + - New variables have been added to allow a deployer to customize + a aodh systemd unit file to their liking. + - The task dropping the aodh 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/aodh_init_systemd.yml b/tasks/aodh_init_systemd.yml index d49f0a1..e4e3eec 100644 --- a/tasks/aodh_init_systemd.yml +++ b/tasks/aodh_init_systemd.yml @@ -54,12 +54,14 @@ when: inventory_hostname in groups[item.value.group] - name: Place the systemd init script - template: + config_template: src: "aodh-systemd-init.j2" dest: "/etc/systemd/system/{{ item.value.service_name }}.service" mode: "0644" owner: "root" group: "root" + config_overrides: "{{ item.value.init_config_overrides }}" + config_type: "ini" with_dict: "{{ aodh_services }}" when: inventory_hostname in groups[item.value.group] notify: diff --git a/templates/aodh-systemd-init.j2 b/templates/aodh-systemd-init.j2 index c9280df..5858750 100644 --- a/templates/aodh-systemd-init.j2 +++ b/templates/aodh-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=aodh.slice +CPUAccounting=true +BlockIOAccounting=true +MemoryAccounting=false +TasksAccounting=true + [Install] WantedBy=multi-user.target