diff options
author | juanvallejo <jvallejo@redhat.com> | 2017-02-27 17:52:02 -0500 |
---|---|---|
committer | juanvallejo <jvallejo@redhat.com> | 2017-04-17 13:29:23 -0400 |
commit | d2955189066364461a846e0e34d344c94b26a16b (patch) | |
tree | aaadb53d649665968140c0b8972d90f62baf4949 /roles/openshift_health_checker/openshift_checks/memory_availability.py | |
parent | cf06e28ac23d13e9fe6e48fe66d033d6ebaaa263 (diff) | |
download | openshift-d2955189066364461a846e0e34d344c94b26a16b.tar.gz openshift-d2955189066364461a846e0e34d344c94b26a16b.tar.bz2 openshift-d2955189066364461a846e0e34d344c94b26a16b.tar.xz openshift-d2955189066364461a846e0e34d344c94b26a16b.zip |
add ram and storage preflight check
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/memory_availability.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/memory_availability.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/memory_availability.py b/roles/openshift_health_checker/openshift_checks/memory_availability.py new file mode 100644 index 000000000..aa54b9535 --- /dev/null +++ b/roles/openshift_health_checker/openshift_checks/memory_availability.py @@ -0,0 +1,35 @@ +# pylint: disable=missing-docstring +from openshift_checks import OpenShiftCheck, get_var + + +class MemoryAvailability(OpenShiftCheck): + """Check that recommended memory is available.""" + + name = "memory_availability" + tags = ["preflight"] + + recommended_memory_mb = { + "nodes": 8 * 1000, + "masters": 16 * 1000, + "etcd": 10 * 1000, + } + + @classmethod + def is_active(cls, task_vars): + """Skip hosts that do not have recommended memory space requirements.""" + group_names = get_var(task_vars, "group_names", default=[]) + has_mem_space_recommendation = bool(set(group_names).intersection(cls.recommended_memory_mb)) + return super(MemoryAvailability, cls).is_active(task_vars) and has_mem_space_recommendation + + def run(self, tmp, task_vars): + group_names = get_var(task_vars, "group_names", default=[]) + total_memory = get_var(task_vars, "ansible_memtotal_mb") + + recommended_memory_mb = max(self.recommended_memory_mb.get(group, 0) for group in group_names) + + if total_memory < recommended_memory_mb: + msg = ("Available memory ({available} MB) below recommended storage. " + "Minimum required memory: {recommended} MB") + return {"failed": True, "msg": msg.format(available=total_memory, recommended=recommended_memory_mb)} + + return {"changed": False} |