From: Kefu Chai Date: Sat, 21 Mar 2020 06:07:40 +0000 (+0800) Subject: cephadm: init config and keyring with None X-Git-Tag: v17.0.0~2858^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=86de901d89b26920c1493e3867ddfafa9f9c95cd;p=ceph.git cephadm: init config and keyring with None 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 Signed-off-by: Michael Fritch --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index cee57ea249b65..94f40224f0e5b 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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,