Browse Source

Do not set cpuset-cpus if cconfig['cpuset_cpus'] == 'all'

In the case of nova_libvirt container, we want to use all CPUs that are
reported online.
Rather than computing the list with Python (which has proven to be
problematic on PPC), let the container engine figuring it out by itself
like it was the case before.

Change-Id: I5d1b88c90dbc4114d996008a407cd1dd9a6eb9da
Closes-Bug: #1868135
(cherry picked from commit 9b62765121)
changes/91/713991/1
Emilien Macchi 3 months ago
parent
commit
341e5f6337
4 changed files with 8 additions and 20 deletions
  1. +6
    -5
      paunch/builder/compose1.py
  2. +2
    -1
      paunch/tests/test_builder_compose1.py
  3. +0
    -6
      paunch/tests/test_utils_common.py
  4. +0
    -8
      paunch/utils/common.py

+ 6
- 5
paunch/builder/compose1.py View File

@@ -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())


+ 2
- 1
paunch/tests/test_builder_compose1.py View File

@@ -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',


+ 0
- 6
paunch/tests/test_utils_common.py View File

@@ -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)

+ 0
- 8
paunch/utils/common.py View File

@@ -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)


Loading…
Cancel
Save