Skip to content

Commit b2326e9

Browse files
authored
Merge pull request #267 from innogames/ndco_4500
Force memory sizes to conform to system memory boundaries
2 parents 4727eda + 5ac9865 commit b2326e9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

igvm/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353

5454
VM_OVERHEAD_MEMORY_MIB = 50
5555

56+
# Prevent creation of VMs with odd memory block size.
57+
# See vm.py for details.
58+
MEM_BLOCK_BOUNDARY_GiB = 63
59+
MEM_BLOCK_SIZE_GiB = 2
60+
5661
# Default max number of CPUs, unless the hypervisor has fewer cores or num_cpu
5762
# is larger than this value.
5863
KVM_DEFAULT_MAX_CPUS = 24

igvm/vm.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
AWS_INSTANCES_OVERVIEW_FILE,
4141
AWS_INSTANCES_OVERVIEW_FILE_ETAG,
4242
AWS_INSTANCES_OVERVIEW_URL,
43+
MEM_BLOCK_BOUNDARY_GiB,
44+
MEM_BLOCK_SIZE_GiB,
4345
)
4446
from igvm.transaction import Transaction
4547
from igvm.utils import parse_size, wait_until
@@ -233,6 +235,27 @@ def check_serveradmin_config(self):
233235
('puppet_master', lambda v: True, 'puppet_master must be set'),
234236
]
235237

238+
# Hosts defined with topmost address higher than MEM_BLOCK_BOUNDARY_GiB will use
239+
# 1GiB or 2GiB memory block size. There is always extra 1GiB address space for
240+
# the PCI bus. A host defined with an even amount of memory ends up with an
241+
# an odd-sized address space and block size of 1GiB. A host with an odd amount
242+
# of memory ends up with an even address space size and block size of 2GiB.
243+
# The latter case makes it problematic to add memory modules: depending on
244+
# their size, which also depends on NUMA layout, they might not align with
245+
# the memory block size.
246+
#
247+
# Enforce memory sizes resulting in block size of 1GiB.
248+
if self.dataset_obj['memory'] >= MEM_BLOCK_BOUNDARY_GiB * 1024 :
249+
validations.extend([
250+
(
251+
'memory',
252+
lambda v: v % (MEM_BLOCK_SIZE_GiB * 1024) == 0,
253+
f'For VMs with memory size of {MEM_BLOCK_BOUNDARY_GiB}GiB or more '
254+
f'it must be a multiple of {MEM_BLOCK_SIZE_GiB}GiB',
255+
),
256+
])
257+
258+
236259
if self.dataset_obj['datacenter_type'] == 'aws.dct':
237260
validations.extend([
238261
('aws_key_name', lambda v: True, 'aws_key_name must be set'),

0 commit comments

Comments
 (0)