blob: 765ba072d13d5c4cbedadb60e8d2683c230f9150 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
"""Check that recommended memory is available."""
from openshift_checks import OpenShiftCheck
MIB = 2**20
GIB = 2**30
class MemoryAvailability(OpenShiftCheck):
"""Check that recommended memory is available."""
name = "memory_availability"
tags = ["preflight"]
# Values taken from the official installation documentation:
# https://docs.openshift.org/latest/install_config/install/prerequisites.html#system-requirements
recommended_memory_bytes = {
"masters": 16 * GIB,
"nodes": 8 * GIB,
"etcd": 8 * GIB,
}
# https://access.redhat.com/solutions/3006511 physical RAM is partly reserved from memtotal
memtotal_adjustment = 1 * GIB
def is_active(self):
"""Skip hosts that do not have recommended memory requirements."""
group_names = self.get_var("group_names", default=[])
has_memory_recommendation = bool(set(group_names).intersection(self.recommended_memory_bytes))
return super(MemoryAvailability, self).is_active() and has_memory_recommendation
def run(self):
group_names = self.get_var("group_names")
total_memory_bytes = self.get_var("ansible_memtotal_mb") * MIB
recommended_min = max(self.recommended_memory_bytes.get(name, 0) for name in group_names)
configured_min = float(self.get_var("openshift_check_min_host_memory_gb", default=0)) * GIB
min_memory_bytes = configured_min or recommended_min
if total_memory_bytes + self.memtotal_adjustment < min_memory_bytes:
return {
'failed': True,
'msg': (
'Available memory ({available:.1f} GiB) is too far '
'below recommended value ({recommended:.1f} GiB)'
).format(
available=float(total_memory_bytes) / GIB,
recommended=float(min_memory_bytes) / GIB,
),
}
return {}
|