diff --git a/paunch/builder/compose1.py b/paunch/builder/compose1.py index 4019153..51fe7b3 100644 --- a/paunch/builder/compose1.py +++ b/paunch/builder/compose1.py @@ -82,12 +82,13 @@ class ComposeV1Builder(base.BaseBuilder): for extra_host in cconfig.get('extra_hosts', []): if extra_host: cmd.append('--add-host=%s' % extra_host) - 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/builder/podman.py b/paunch/builder/podman.py index eb3cf08..7d097a2 100644 --- a/paunch/builder/podman.py +++ b/paunch/builder/podman.py @@ -91,12 +91,13 @@ class PodmanBuilder(base.BaseBuilder): for extra_host in cconfig.get('extra_hosts', []): if extra_host: cmd.append('--add-host=%s' % extra_host) - 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_base.py b/paunch/tests/test_builder_base.py index f52bfc4..51df837 100644 --- a/paunch/tests/test_builder_base.py +++ b/paunch/tests/test_builder_base.py @@ -36,7 +36,6 @@ class TestBaseBuilder(base.TestCase): 'one': { 'start_order': 0, 'image': 'centos:7', - 'cpuset_cpus': '', }, 'two': { 'start_order': 1, diff --git a/paunch/tests/test_builder_compose1.py b/paunch/tests/test_builder_compose1.py index c65242d..92acafa 100644 --- a/paunch/tests/test_builder_compose1.py +++ b/paunch/tests/test_builder_compose1.py @@ -41,6 +41,7 @@ class TestComposeV1Builder(tbb.TestBaseBuilder): 'env_file': '/tmp/foo.env', 'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}', 'cpu_shares': 600, + 'cpuset_cpus': 'all', 'mem_limit': '1G', 'memswap_limit': '1G', 'mem_swappiness': '60', @@ -77,7 +78,6 @@ class TestComposeV1Builder(tbb.TestBaseBuilder): '--hostname=foohostname', '--add-host=foohost:127.0.0.1', '--add-host=barhost:127.0.0.2', - '--cpuset-cpus=0,1,2,3', '--cap-add=SYS_ADMIN', '--cap-add=SETUID', '--cap-drop=NET_RAW', 'centos:7'], cmd diff --git a/paunch/tests/test_utils_common.py b/paunch/tests/test_utils_common.py index 1e8a9ef..88654d5 100644 --- a/paunch/tests/test_utils_common.py +++ b/paunch/tests/test_utils_common.py @@ -27,12 +27,6 @@ class TestUtilsCommonCpu(base.TestCase): 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) - class TestUtilsCommonConfig(base.TestCase): diff --git a/paunch/utils/common.py b/paunch/utils/common.py index a2ebffa..7c79377 100644 --- a/paunch/utils/common.py +++ b/paunch/utils/common.py @@ -78,14 +78,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 load_config(config, name=None, overrides=None): container_config = {} if overrides is None: