From acb63a57faac533e07dcd178b5c75484ab8d0fd2 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Wed, 25 Oct 2017 10:25:15 +0100 Subject: [PATCH] Only limit etcd memory on small hosts (#1860) Also disable oom killer on etcd --- roles/etcd/defaults/main.yml | 3 ++- roles/etcd/templates/etcd.j2 | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/etcd/defaults/main.yml b/roles/etcd/defaults/main.yml index 61a7386b5..e2b1b83c7 100644 --- a/roles/etcd/defaults/main.yml +++ b/roles/etcd/defaults/main.yml @@ -17,7 +17,8 @@ etcd_election_timeout: "5000" etcd_metrics: "basic" # Limits -etcd_memory_limit: 512M +# Limit memory only if <4GB memory on host. 0=unlimited +etcd_memory_limit: "{% if ansible_memtotal_mb < 4096 %}512M{% else %}0{% endif %}" # Uncomment to set CPU share for etcd # etcd_cpu_limit: 300m diff --git a/roles/etcd/templates/etcd.j2 b/roles/etcd/templates/etcd.j2 index 9ac08e073..d916a7570 100644 --- a/roles/etcd/templates/etcd.j2 +++ b/roles/etcd/templates/etcd.j2 @@ -9,6 +9,7 @@ {% if etcd_memory_limit is defined %} --memory={{ etcd_memory_limit|regex_replace('Mi', 'M') }} \ {% endif %} + --oom-kill-disable \ {% if etcd_cpu_limit is defined %} --cpu-shares={{ etcd_cpu_limit|regex_replace('m', '') }} \ {% endif %}