Try implementing fedmsg memory limit on RHEL 7

This commit is contained in:
Mikolaj Izdebski 2019-02-21 18:25:36 +01:00
parent 8cf6d4f021
commit 29c150fcff
3 changed files with 8 additions and 8 deletions

View file

@ -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:

View file

@ -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

View file

@ -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 %}