Do not support dimensions:kernel_memory on Docker API 1.42

It is deprecated in 20.10 and removed in 23.0 (and 23.0 is out) [1], [2].

[1]: https://docs.docker.com/engine/deprecated/#kernel-memory-limit
[2]: https://docs.docker.com/engine/api/version-history/#v142-api-changes

Change-Id: Ia6fa85172aad7bcd5f958922d3c224ef79882e6c
This commit is contained in:
Michal Nasiadka 2023-02-02 15:08:42 +01:00
parent 66ec9cef55
commit f253f99c12
3 changed files with 40 additions and 2 deletions

View File

@ -50,6 +50,8 @@ class DockerWorker(object):
self._cgroupns_mode_supported = ( self._cgroupns_mode_supported = (
StrictVersion(self.dc._version) >= StrictVersion('1.41')) StrictVersion(self.dc._version) >= StrictVersion('1.41'))
self._dimensions_kernel_memory_removed = (
StrictVersion(self.dc._version) >= StrictVersion('1.42'))
self.systemd = SystemdWorker(self.params) self.systemd = SystemdWorker(self.params)
@ -310,8 +312,11 @@ class DockerWorker(object):
'memswap_limit': 'MemorySwap', 'cpu_period': 'CpuPeriod', 'memswap_limit': 'MemorySwap', 'cpu_period': 'CpuPeriod',
'cpu_quota': 'CpuQuota', 'cpu_shares': 'CpuShares', 'cpu_quota': 'CpuQuota', 'cpu_shares': 'CpuShares',
'cpuset_cpus': 'CpusetCpus', 'cpuset_mems': 'CpusetMems', 'cpuset_cpus': 'CpusetCpus', 'cpuset_mems': 'CpusetMems',
'kernel_memory': 'KernelMemory', 'blkio_weight': 'BlkioWeight', 'blkio_weight': 'BlkioWeight', 'ulimits': 'Ulimits'}
'ulimits': 'Ulimits'}
if not self._dimensions_kernel_memory_removed:
dimension_map['kernel_memory'] = 'KernelMemory'
unsupported = set(new_dimensions.keys()) - \ unsupported = set(new_dimensions.keys()) - \
set(dimension_map.keys()) set(dimension_map.keys())
if unsupported: if unsupported:

View File

@ -49,6 +49,14 @@
- python3-pip - python3-pip
- python3-setuptools - python3-setuptools
# TODO(mnasiadka): Remove this once ansible-collection-kolla
# installs apparmor
- name: Install apparmor on Debian/Ubuntu
become: true
package:
name: apparmor
when: ansible_os_family == 'Debian'
- name: Ensure /tmp/logs/ dir - name: Ensure /tmp/logs/ dir
file: file:
path: "{{ logs_dir }}" path: "{{ logs_dir }}"

View File

@ -269,6 +269,15 @@ class TestMainModule(base.BaseTestCase):
docker_api_version='1.41') docker_api_version='1.41')
self.assertTrue(self.dw._cgroupns_mode_supported) self.assertTrue(self.dw._cgroupns_mode_supported)
def test_sets_dimensions_kernelmemory_supported_true(self):
self.dw = get_DockerWorker(self.fake_data['params'])
self.assertFalse(self.dw._dimensions_kernel_memory_removed)
def test_sets_dimensions_kernelmemory_supported_false(self):
self.dw = get_DockerWorker(self.fake_data['params'],
docker_api_version='1.42')
self.assertTrue(self.dw._dimensions_kernel_memory_removed)
class TestContainer(base.BaseTestCase): class TestContainer(base.BaseTestCase):
@ -1396,6 +1405,22 @@ class TestAttrComp(base.BaseTestCase):
self.dw = get_DockerWorker(self.fake_data['params']) self.dw = get_DockerWorker(self.fake_data['params'])
self.assertFalse(self.dw.compare_dimensions(container_info)) self.assertFalse(self.dw.compare_dimensions(container_info))
def test_compare_dimensions_kernel_memory_1_42(self):
self.fake_data['params']['dimensions'] = {
'kernel_memory': '1024'}
container_info = dict()
container_info['HostConfig'] = {
'CpuPeriod': 0, 'Memory': 0, 'CpuQuota': 0,
'CpusetCpus': '', 'CpuShares': 0, 'BlkioWeight': 0,
'CpusetMems': '', 'MemorySwap': 0, 'MemoryReservation': 0,
'Ulimits': []}
self.dw = get_DockerWorker(self.fake_data['params'],
docker_api_version='1.42')
self.dw.compare_dimensions(container_info)
self.dw.module.exit_json.assert_called_once_with(
failed=True, msg=repr("Unsupported dimensions"),
unsupported_dimensions=set(['kernel_memory']))
def test_compare_container_state_pos(self): def test_compare_container_state_pos(self):
container_info = {'State': dict(Status='running')} container_info = {'State': dict(Status='running')}
self.dw = get_DockerWorker({'state': 'exited'}) self.dw = get_DockerWorker({'state': 'exited'})