]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: init config and keyring with None 34108/head
authorKefu Chai <kchai@redhat.com>
Sat, 21 Mar 2020 06:07:40 +0000 (14:07 +0800)
committerMichael Fritch <mfritch@suse.com>
Sun, 22 Mar 2020 18:17:41 +0000 (12:17 -0600)
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>
src/cephadm/cephadm

index cee57ea249b6557c0fc10b7c2928add9a5eb6cd3..94f40224f0e5b1cddcdb63f888ddcb489a28d30f 100755 (executable)
@@ -1339,7 +1339,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')
@@ -1355,11 +1358,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,
@@ -2602,14 +2600,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,