Include swap in memory check
It's not uncommon for developers to use SSD-backed swap to allow for more instances on a limited memory baremetal system. Previously this was not allowed by the memory check because it only looked at physical memory. This change includes swap in the memory check so that use case is supported out of the box. Change-Id: If7fdf189fadd39cd6380c15a35f4b7d49cc42a96
This commit is contained in:
parent
553e04563e
commit
0b20c8f119
|
@ -240,18 +240,33 @@ class TestCheckHostname(BaseTestCase):
|
|||
|
||||
|
||||
class TestCheckMemory(BaseTestCase):
|
||||
@mock.patch('psutil.swap_memory')
|
||||
@mock.patch('psutil.virtual_memory')
|
||||
def test_sufficient_memory(self, mock_vm):
|
||||
def test_sufficient_memory(self, mock_vm, mock_sm):
|
||||
mock_vm.return_value = mock.Mock()
|
||||
mock_vm.return_value.total = 8589934592
|
||||
mock_sm.return_value = mock.Mock()
|
||||
mock_sm.return_value.total = 0
|
||||
undercloud._check_memory()
|
||||
|
||||
@mock.patch('psutil.swap_memory')
|
||||
@mock.patch('psutil.virtual_memory')
|
||||
def test_insufficient_memory(self, mock_vm):
|
||||
def test_insufficient_memory(self, mock_vm, mock_sm):
|
||||
mock_vm.return_value = mock.Mock()
|
||||
mock_vm.return_value.total = 2071963648
|
||||
mock_sm.return_value = mock.Mock()
|
||||
mock_sm.return_value.total = 0
|
||||
self.assertRaises(RuntimeError, undercloud._check_memory)
|
||||
|
||||
@mock.patch('psutil.swap_memory')
|
||||
@mock.patch('psutil.virtual_memory')
|
||||
def test_sufficient_swap(self, mock_vm, mock_sm):
|
||||
mock_vm.return_value = mock.Mock()
|
||||
mock_vm.return_value.total = 6442450944
|
||||
mock_sm.return_value = mock.Mock()
|
||||
mock_sm.return_value.total = 2147483648
|
||||
undercloud._check_memory()
|
||||
|
||||
|
||||
class TestCheckSysctl(BaseTestCase):
|
||||
@mock.patch('os.path.isfile')
|
||||
|
|
|
@ -607,7 +607,8 @@ def _check_memory():
|
|||
proceeding with install.
|
||||
"""
|
||||
mem = psutil.virtual_memory()
|
||||
total_mb = mem.total / 1024 / 1024
|
||||
swap = psutil.swap_memory()
|
||||
total_mb = (mem.total + swap.total) / 1024 / 1024
|
||||
if total_mb < REQUIRED_MB:
|
||||
LOG.error('At least %d MB of memory is required for undercloud '
|
||||
'installation. A minimum of 8 GB is recommended. '
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
other:
|
||||
- |
|
||||
Swap memory is now included in the minimum memory check. While relying on
|
||||
swap is still not recommended for production deployments, it is not
|
||||
uncommon for developers to use SSD-backed swap to fit more instances into
|
||||
a system with limited memory.
|
Loading…
Reference in New Issue