From cdcd5950dd5fcf9a6df89f43eaa1181ffb1a526a Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 7 Aug 2020 16:51:26 +0200 Subject: [PATCH] mgr/cephadm: extract set_continer_image(entity, image) Signed-off-by: Sebastian Wagner (cherry picked from commit 8da1f38e92c3fc8d15d2a7d364b7455a26d9fe9b) --- src/pybind/mgr/cephadm/module.py | 8 ++++++++ src/pybind/mgr/cephadm/tests/test_upgrade.py | 7 +------ src/pybind/mgr/cephadm/upgrade.py | 15 +++------------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index d62ec3fc1bc1b..ee900791ef4d0 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -526,6 +526,14 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self._serve_sleep() self.log.debug("serve exit") + def set_container_image(self, entity: str, image): + self.check_mon_command({ + 'prefix': 'config set', + 'name': 'container_image', + 'value': image, + 'who': entity, + }) + def _update_paused_health(self): if self.paused: self.health_checks['CEPHADM_PAUSED'] = { diff --git a/src/pybind/mgr/cephadm/tests/test_upgrade.py b/src/pybind/mgr/cephadm/tests/test_upgrade.py index 51dcc8e80fba4..60ed7c13fffce 100644 --- a/src/pybind/mgr/cephadm/tests/test_upgrade.py +++ b/src/pybind/mgr/cephadm/tests/test_upgrade.py @@ -25,12 +25,7 @@ def test_upgrade_start(cephadm_module: CephadmOrchestrator): @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) def test_upgrade_run(cephadm_module: CephadmOrchestrator): with with_host(cephadm_module, 'test'): - cephadm_module.check_mon_command({ - 'prefix': 'config set', - 'name': 'container_image', - 'value': 'from_image', - 'who': 'global', - }) + cephadm_module.set_container_image('global', 'from_image') with with_service(cephadm_module, ServiceSpec('mgr'), CephadmOrchestrator.apply_mgr, 'test'): assert wait(cephadm_module, cephadm_module.upgrade_start( 'to_image', None)) == 'Initiating upgrade to to_image' diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index 22bc9a71da0be..285fcbc89962c 100644 --- a/src/pybind/mgr/cephadm/upgrade.py +++ b/src/pybind/mgr/cephadm/upgrade.py @@ -352,12 +352,7 @@ class CephadmUpgrade: if image_settings.get(daemon_type) != target_name: logger.info('Upgrade: Setting container_image for all %s...' % daemon_type) - ret, out, err = self.mgr.check_mon_command({ - 'prefix': 'config set', - 'name': 'container_image', - 'value': target_name, - 'who': name_to_config_section(daemon_type), - }) + self.mgr.set_container_image(name_to_config_section(daemon_type), target_name) to_clean = [] for section in image_settings.keys(): if section.startswith(name_to_config_section(daemon_type) + '.'): @@ -377,12 +372,8 @@ class CephadmUpgrade: # clean up logger.info('Upgrade: Finalizing container_image settings') - ret, out, err = self.mgr.check_mon_command({ - 'prefix': 'config set', - 'name': 'container_image', - 'value': target_name, - 'who': 'global', - }) + self.mgr.set_container_image('global', target_name) + for daemon_type in CEPH_UPGRADE_ORDER: ret, image, err = self.mgr.check_mon_command({ 'prefix': 'config rm', -- 2.39.5