]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: extract set_continer_image(entity, image)
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 7 Aug 2020 14:51:26 +0000 (16:51 +0200)
committerNathan Cutler <ncutler@suse.com>
Tue, 6 Oct 2020 09:40:52 +0000 (11:40 +0200)
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit 8da1f38e92c3fc8d15d2a7d364b7455a26d9fe9b)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_upgrade.py
src/pybind/mgr/cephadm/upgrade.py

index d62ec3fc1bc1b05bae8ceca1637ded349d79918a..ee900791ef4d02cf37f23a187af77dba7b8ed227 100644 (file)
@@ -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'] = {
index 51dcc8e80fba4515fcd2572393278a6f19be4e4a..60ed7c13fffce0288576a9fa0c3323737c7af87c 100644 (file)
@@ -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'
index 22bc9a71da0beca8b7e18a304534a4b402db823e..285fcbc89962cff87fbe4d92cdf73046161de5ac 100644 (file)
@@ -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',