Merge "disable image gc when doing k8s upgrade"
This commit is contained in:
commit
1ab7375abe
|
@ -15958,6 +15958,22 @@ class ConductorManager(service.PeriodicService):
|
||||||
else:
|
else:
|
||||||
next_versions = [kube_version]
|
next_versions = [kube_version]
|
||||||
|
|
||||||
|
# For simplex systems, disable image garbage collection by kubelet
|
||||||
|
# during the K8s upgrade. For duplex this will be done on each controller
|
||||||
|
# by the puppet manifest called below. It wants to be done before we
|
||||||
|
# pull the images so that they can't be garbage collected by kubelet
|
||||||
|
# before they're needed.
|
||||||
|
if system.system_mode == constants.SYSTEM_MODE_SIMPLEX:
|
||||||
|
try:
|
||||||
|
# Call the helper script used by the puppet manifest.
|
||||||
|
subprocess.check_call( # pylint: disable=not-callable
|
||||||
|
["/bin/bash",
|
||||||
|
"/usr/share/puppet/modules/platform/files/disable_image_gc.sh"],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
LOG.error("Failed to call disable_image_gc.sh, continuing anyway.")
|
||||||
|
|
||||||
for k8s_version in next_versions:
|
for k8s_version in next_versions:
|
||||||
LOG.info("executing playbook: %s for version %s" %
|
LOG.info("executing playbook: %s for version %s" %
|
||||||
(constants.ANSIBLE_KUBE_PUSH_IMAGES_PLAYBOOK, k8s_version))
|
(constants.ANSIBLE_KUBE_PUSH_IMAGES_PLAYBOOK, k8s_version))
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
import copy
|
import copy
|
||||||
import mock
|
import mock
|
||||||
import os.path
|
import os.path
|
||||||
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
@ -1051,6 +1052,13 @@ class ManagerTestCase(base.DbTestCase):
|
||||||
p.start().return_value = ['v1.42.2', 'v1.43.1']
|
p.start().return_value = ['v1.42.2', 'v1.43.1']
|
||||||
self.addCleanup(p.stop)
|
self.addCleanup(p.stop)
|
||||||
|
|
||||||
|
# Mock subprocess check_call
|
||||||
|
mock_check_call = mock.MagicMock()
|
||||||
|
p = mock.patch('eventlet.green.subprocess.check_call', mock_check_call)
|
||||||
|
mock_subprocess_check_call = p.start()
|
||||||
|
mock_subprocess_check_call.return_value = 0
|
||||||
|
self.addCleanup(p.stop)
|
||||||
|
|
||||||
next_versions = kubernetes.KubeOperator().kube_get_higher_patch_version('v1.41.1',
|
next_versions = kubernetes.KubeOperator().kube_get_higher_patch_version('v1.41.1',
|
||||||
'v1.43.1')
|
'v1.43.1')
|
||||||
mock_run_playbook = mock.MagicMock()
|
mock_run_playbook = mock.MagicMock()
|
||||||
|
@ -1067,6 +1075,13 @@ class ManagerTestCase(base.DbTestCase):
|
||||||
constants.ANSIBLE_KUBE_PUSH_IMAGES_PLAYBOOK]
|
constants.ANSIBLE_KUBE_PUSH_IMAGES_PLAYBOOK]
|
||||||
mock_run_playbook.assert_any_call(playbook_cmd)
|
mock_run_playbook.assert_any_call(playbook_cmd)
|
||||||
|
|
||||||
|
# Verify that we called the script to turn off image garbage collection
|
||||||
|
mock_subprocess_check_call.assert_called_with(
|
||||||
|
["/bin/bash", "/usr/share/puppet/modules/platform/files/disable_image_gc.sh"],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
|
||||||
# Verify that the upgrade state was updated
|
# Verify that the upgrade state was updated
|
||||||
updated_upgrade = self.dbapi.kube_upgrade_get_one()
|
updated_upgrade = self.dbapi.kube_upgrade_get_one()
|
||||||
self.assertEqual(updated_upgrade.state,
|
self.assertEqual(updated_upgrade.state,
|
||||||
|
|
Loading…
Reference in New Issue