]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: remove call to get_parm from fetch_configs
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 15 Jun 2023 19:54:09 +0000 (15:54 -0400)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:15 +0000 (13:35 -0400)
Stop using get_parm in fetch_configs. Doing so makes clear that
the two if-branches in fetch_configs are symmetric, in the
handling of custom_config_files and symmetric with the behavior
of fetch_custom_config_files.
It also reveals that get_parm only has one remaining caller making it
simpler to remove get_parm in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_cephadm.py

index bd5bb59422b72f22f6fa9f067a8f0db9c10918fb..43d1f0a88d225b858f7ad5625afb5f8425fb0570 100755 (executable)
@@ -3056,14 +3056,21 @@ def fetch_configs(ctx: CephadmContext) -> Dict[str, str]:
     must not be part of a deployment's configuration key-value pairs.
     To access custom configuration file data, use `fetch_custom_config_files`.
     """
+    # ctx.config_blobs is *always* a dict. it is created once when
+    # a command is parsed/processed and stored "forever"
     cfg_blobs = getattr(ctx, 'config_blobs', None)
     if cfg_blobs:
         cfg_blobs = dict(cfg_blobs)
         cfg_blobs.pop('custom_config_files', None)
         return cfg_blobs
+    # ctx.config_json is the legacy equivalent of config_blobs. it is a
+    # string that either contains json or refers to a file name where
+    # the file contains json.
     cfg_json = getattr(ctx, 'config_json', None)
     if cfg_json:
-        return get_parm(cfg_json) or {}
+        jdata = _get_config_json(cfg_json) or {}
+        jdata.pop('custom_config_files', None)
+        return jdata
     return {}
 
 
index ae1c18249be4fc0fd62c3898ca6272e335a8bd52..ed09f91d54c5de8b7301db234386264e3b199420 100644 (file)
@@ -306,7 +306,7 @@ class TestCephAdm(object):
     @mock.patch('cephadm.logger')
     @mock.patch('cephadm.FileLock')
     @mock.patch('cephadm.deploy_daemon')
-    @mock.patch('cephadm.get_parm')
+    @mock.patch('cephadm.fetch_configs')
     @mock.patch('cephadm.make_var_run')
     @mock.patch('cephadm.migrate_sysctl_dir')
     @mock.patch('cephadm.check_unit', lambda *args, **kwargs: (None, 'running', None))
@@ -314,7 +314,7 @@ class TestCephAdm(object):
     @mock.patch('cephadm.get_deployment_container')
     @mock.patch('cephadm.read_configuration_source', lambda c: {})
     @mock.patch('cephadm.apply_deploy_config_to_ctx', lambda d, c: None)
-    def test_mon_crush_location(self, _get_deployment_container, _migrate_sysctl, _make_var_run, _get_parm, _deploy_daemon, _file_lock, _logger):
+    def test_mon_crush_location(self, _get_deployment_container, _migrate_sysctl, _make_var_run, _fetch_configs, _deploy_daemon, _file_lock, _logger):
         """
         test that crush location for mon is set if it is included in config_json
         """
@@ -328,7 +328,7 @@ class TestCephAdm(object):
         ctx.config_json = '-'
         ctx.osd_fsid = '0'
         ctx.tcp_ports = '3300 6789'
-        _get_parm.return_value = {
+        _fetch_configs.return_value = {
             'crush_location': 'database=a'
         }