diff --git a/paunch/builder/compose1.py b/paunch/builder/compose1.py index d5f302c..9aa00e0 100644 --- a/paunch/builder/compose1.py +++ b/paunch/builder/compose1.py @@ -195,12 +195,13 @@ class ComposeV1Builder(object): cmd.append('--cpu-shares=%s' % cconfig['cpu_shares']) if 'security_opt' in cconfig: cmd.append('--security-opt=%s' % cconfig['security_opt']) - if 'cpuset_cpus' in cconfig and cconfig['cpuset_cpus'] != '': + if 'cpuset_cpus' in cconfig: # 'all' is a special value to directly configure all CPUs - # that are available. - if cconfig['cpuset_cpus'] == 'all': - cmd.append('--cpuset-cpus=%s' % common.get_all_cpus()) - else: + # that are available. Without specifying --cpuset-cpus, we'll + # let the container engine to figure out what CPUs are online. + # https://bugs.launchpad.net/tripleo/+bug/1868135 + # https://bugzilla.redhat.com/show_bug.cgi?id=1813091 + if cconfig['cpuset_cpus'] != 'all': cmd.append('--cpuset-cpus=%s' % cconfig['cpuset_cpus']) else: cmd.append('--cpuset-cpus=%s' % common.get_cpus_allowed_list()) diff --git a/paunch/tests/test_builder_compose1.py b/paunch/tests/test_builder_compose1.py index cd18045..4668a2d 100644 --- a/paunch/tests/test_builder_compose1.py +++ b/paunch/tests/test_builder_compose1.py @@ -458,6 +458,7 @@ three-12345678 three''', '', 0), 'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}', 'cpu_shares': 600, 'security_opt': 'label:disable', + 'cpuset_cpus': 'all', 'mem_limit': '1G', 'memswap_limit': '1G', 'mem_swappiness': '60' @@ -476,7 +477,7 @@ three-12345678 three''', '', 0), '--privileged=true', '--restart=always', '--user=bar', '--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}', '--cpu-shares=600', - '--security-opt=label:disable', '--cpuset-cpus=0,1,2,3', + '--security-opt=label:disable', '--memory=1G', '--memory-swap=1G', '--memory-swappiness=60', diff --git a/paunch/tests/test_utils_common.py b/paunch/tests/test_utils_common.py index 65f18b6..9442916 100644 --- a/paunch/tests/test_utils_common.py +++ b/paunch/tests/test_utils_common.py @@ -26,9 +26,3 @@ class TestUtilsCommon(base.TestCase): expected_list = '0,1,2,3' actual_list = common.get_cpus_allowed_list() self.assertEqual(actual_list, expected_list) - - @mock.patch("psutil.cpu_count", return_value=4) - def test_get_all_cpus(self, mock_cpu): - expected_list = '0-3' - actual_list = common.get_all_cpus() - self.assertEqual(actual_list, expected_list) diff --git a/paunch/utils/common.py b/paunch/utils/common.py index 0b74179..2ee6713 100644 --- a/paunch/utils/common.py +++ b/paunch/utils/common.py @@ -26,14 +26,6 @@ def get_cpus_allowed_list(**args): return ','.join([str(c) for c in psutil.Process().cpu_affinity()]) -def get_all_cpus(**args): - """Returns a single list of all CPUs. - - :return: Value computed by psutil, e.g. '0-3' - """ - return "0-" + str(psutil.cpu_count() - 1) - - def configure_logging(name, level=3, log_file=None): '''Mimic oslo_log default levels and formatting for the logger. ''' log = logging.getLogger(name)