From 29c150fcff9fb092b3b987c49bd363648f2cdeb0 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 21 Feb 2019 18:25:36 +0100 Subject: [PATCH] Try implementing fedmsg memory limit on RHEL 7 --- inventory/group_vars/odcs-backend-stg | 2 +- roles/fedmsg/hub/defaults/main.yml | 7 +++---- roles/fedmsg/hub/templates/fedmsg-hub-systemd.conf.j2 | 7 ++++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/inventory/group_vars/odcs-backend-stg b/inventory/group_vars/odcs-backend-stg index 055241592a..4d71ded139 100644 --- a/inventory/group_vars/odcs-backend-stg +++ b/inventory/group_vars/odcs-backend-stg @@ -36,7 +36,7 @@ custom_rules: [ '-A INPUT -p tcp -m tcp -s 10.5.126.13 --dport 873 -j ACCEPT', ' fas_client_groups: sysadmin-noc,sysadmin-releng,sysadmin-mbs,sysadmin-veteran # Set very low memory limit, for testing. -fedmsg_hub_memory_limit: 10M +fedmsg_hub_memory_limit_mb: 10 # These are consumed by a task in roles/fedmsg/base/main.yml fedmsg_certs: diff --git a/roles/fedmsg/hub/defaults/main.yml b/roles/fedmsg/hub/defaults/main.yml index 5777dc3db9..baf63f63e1 100644 --- a/roles/fedmsg/hub/defaults/main.yml +++ b/roles/fedmsg/hub/defaults/main.yml @@ -1,10 +1,9 @@ # This is false by default. You have to override it when including the role. enable_websocket_server: False -# Absolute memory limit in bytes for fedmsg-hub and fedmsg-bub-3 -# services. The value the value can be suffixed with K, M, G or T. -# Zero means infinity (no limit). -fedmsg_hub_memory_limit: 0 +# Absolute memory limit in megabytes for fedmsg-hub and fedmsg-bub-3 +# services. Zero means infinity (no limit). +fedmsg_hub_memory_limit_mb: 0 # Restart fedmsg-hub.service on failure. fedmsg_hub_auto_restart: False diff --git a/roles/fedmsg/hub/templates/fedmsg-hub-systemd.conf.j2 b/roles/fedmsg/hub/templates/fedmsg-hub-systemd.conf.j2 index bdbf5d4361..6f67744137 100644 --- a/roles/fedmsg/hub/templates/fedmsg-hub-systemd.conf.j2 +++ b/roles/fedmsg/hub/templates/fedmsg-hub-systemd.conf.j2 @@ -1,15 +1,16 @@ [Service] -{% if fedmsg_hub_memory_limit %} +{% if fedmsg_hub_memory_limit_mb %} {% if ansible_distribution_major_version|int > 7 %} # Don't let fedmsg-hub use more that half of swap available in the # system, so that we don't get Nagios alerts about low swap. We would # rather have fedmsg-hub OOM and be auto-restarted. MemorySwapMax={{ ansible_memory_mb.swap.total / 2 }}M # Limit RAM usage too -MemoryMax={{fedmsg_hub_memory_limit}} +MemoryMax={{fedmsg_hub_memory_limit_mb}}M {% else %} # On RHEL 7 we can only control RAM usage. -MemoryLimit={{fedmsg_hub_memory_limit}} +MemoryLimit={{fedmsg_hub_memory_limit_mb}}M +LimitAS={{ fedmsg_hub_memory_limit_mb + (ansible_memory_mb.swap.total / 2) }}M {% endif %} {% endif %}