From 5f6a51e178d9f1539c4776230f16176a15445d63 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 8 May 2020 15:15:06 -0700 Subject: [PATCH] Set default to prevent out of memory conditions Change-Id: I00efd4784346adb89b137424ed35bdeafe9b6f24 --- ironic/conf/default.py | 2 +- ironic/tests/unit/common/test_utils.py | 15 +++++++++++++-- ...waits-when-low-on-memory-d73892a79cde0516.yaml | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/conductor-now-waits-when-low-on-memory-d73892a79cde0516.yaml diff --git a/ironic/conf/default.py b/ironic/conf/default.py index 0951180134..191dee95d1 100644 --- a/ironic/conf/default.py +++ b/ironic/conf/default.py @@ -354,7 +354,7 @@ service_opts = [ 'conductor and API services')), cfg.BoolOpt('minimum_memory_warning_only', mutable=True, - default=True, + default=False, help=_('Setting to govern if Ironic should only warn instead ' 'of attempting to hold back the request in order to ' 'prevent the exhaustion of system memory.')), diff --git a/ironic/tests/unit/common/test_utils.py b/ironic/tests/unit/common/test_utils.py index e39a8f7dbf..9bfcddb863 100644 --- a/ironic/tests/unit/common/test_utils.py +++ b/ironic/tests/unit/common/test_utils.py @@ -452,7 +452,6 @@ class TempFilesTestCase(base.TestCase): @mock.patch.object(time, 'sleep', autospec=True) @mock.patch.object(psutil, 'virtual_memory', autospec=True) def test_is_memory_insufficent(self, mock_vm_check, mock_sleep): - self.config(minimum_memory_warning_only=False) class vm_check(object): available = 1000000000 @@ -465,7 +464,6 @@ class TempFilesTestCase(base.TestCase): @mock.patch.object(psutil, 'virtual_memory', autospec=True) def test_is_memory_insufficent_good(self, mock_vm_check, mock_sleep): - self.config(minimum_memory_warning_only=False) class vm_check(object): available = 3276700000 @@ -492,6 +490,19 @@ class TempFilesTestCase(base.TestCase): self.assertFalse(utils.is_memory_insufficent()) self.assertEqual(3, mock_vm_check.call_count) + @mock.patch.object(time, 'sleep', autospec=True) + @mock.patch.object(psutil, 'virtual_memory', autospec=True) + def test_is_memory_insufficent_warning_only(self, mock_vm_check, + mock_sleep): + self.config(minimum_memory_warning_only=True) + + class vm_check_bad(object): + available = 1023000000 + + mock_vm_check.side_effect = vm_check_bad + self.assertFalse(utils.is_memory_insufficent()) + self.assertEqual(2, mock_vm_check.call_count) + class GetUpdatedCapabilitiesTestCase(base.TestCase): diff --git a/releasenotes/notes/conductor-now-waits-when-low-on-memory-d73892a79cde0516.yaml b/releasenotes/notes/conductor-now-waits-when-low-on-memory-d73892a79cde0516.yaml new file mode 100644 index 0000000000..4c86761820 --- /dev/null +++ b/releasenotes/notes/conductor-now-waits-when-low-on-memory-d73892a79cde0516.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + By default Ironic will now not start new memory intensive work IF + insufficent system memory exists. This can be disabled by setting + the ``[DEFAULT]minimum_memory_warning_only`` value to ``True``.