]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: init config and keyring with None 34156/head
authorKefu Chai <kchai@redhat.com>
Sat, 21 Mar 2020 06:07:40 +0000 (14:07 +0800)
committerSage Weil <sage@redhat.com>
Wed, 25 Mar 2020 21:35:11 +0000 (16:35 -0500)
and we should not assume that both `config` and `keying` are specified
when calling this method. because, for instance, `create_daemon_dirs()`
does handle the case where `config` and/or `keyring` is not specified.

this is a follow-up fix of 245d6a5cec9cc0f299613b8cc0415e494a4c3ac5

Signed-off-by: Kefu Chai <kchai@redhat.com>
Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit 86de901d89b26920c1493e3867ddfafa9f9c95cd)

src/cephadm/cephadm

index c89ce1dea928f998fd59abec26b98a5371c387c9..79b11bc549af3b0ac2d87ed700e523ecc50e77c4 100755 (executable)
@@ -1370,7 +1370,10 @@ def get_parm(option):
         return js
 
 def get_config_and_keyring():
-    # type: () -> Tuple[str, str]
+    # type: () -> Tuple[Optional[str], Optional[str]]
+    config = None
+    keyring = None
+
     if 'config_json' in args and args.config_json:
         d = get_parm(args.config_json)
         config = d.get('config')
@@ -1386,11 +1389,6 @@ def get_config_and_keyring():
         with open(args.keyring, 'r') as f:
             keyring = f.read()
 
-    if not config:
-        raise Error('no config provided')
-    elif not keyring:
-        raise Error('no keyring provided')
-
     return (config, keyring)
 
 def get_container_mounts(fsid, daemon_type, daemon_id,
@@ -2639,14 +2637,15 @@ def command_ceph_volume():
 
     (config, keyring) = get_config_and_keyring()
 
-    # tmp keyring file
-    tmp_keyring = write_tmp(keyring, uid, gid)
-
-    # tmp config file
-    tmp_config = write_tmp(config, uid, gid)
+    if config:
+        # tmp config file
+        tmp_config = write_tmp(config, uid, gid)
+        mounts[tmp_config.name] = '/etc/ceph/ceph.conf:z'
 
-    mounts[tmp_config.name] = '/etc/ceph/ceph.conf:z'
-    mounts[tmp_keyring.name] = '/var/lib/ceph/bootstrap-osd/ceph.keyring:z'
+    if keyring:
+        # tmp keyring file
+        tmp_keyring = write_tmp(keyring, uid, gid)
+        mounts[tmp_keyring.name] = '/var/lib/ceph/bootstrap-osd/ceph.keyring:z'
 
     c = CephContainer(
         image=args.image,