From a0fc82af238bae9ba03771d22cbd48ac48f22c2d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 16 Dec 2019 15:16:13 -0600 Subject: [PATCH] cephadm: add --reconfig option for 'deploy' We could make this a totally separate command from 'deploy', but so much of the code path is shared that this is a lot simpler. Signed-off-by: Sage Weil --- src/cephadm/cephadm | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 8e5eacf002f..d3ce18df718 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -707,8 +707,9 @@ def get_daemon_args(fsid, daemon_type, daemon_id): return r def create_daemon_dirs(fsid, daemon_type, daemon_id, uid, gid, - config=None, keyring=None): - # type: (str, str, Union[int, str], int, int, str, str) -> None + config=None, keyring=None, + reconfig=False): + # type: (str, str, Union[int, str], int, int, Optional[str], Optional[str], Optional[bool]) -> None data_dir = make_data_dir(fsid, daemon_type, daemon_id, uid=uid, gid=gid) make_log_dir(fsid, uid=uid, gid=gid) @@ -929,10 +930,13 @@ def extract_uid_gid(img='', file_path='/var/lib/ceph'): def deploy_daemon(fsid, daemon_type, daemon_id, c, uid, gid, config=None, keyring=None, - osd_fsid=None): - # type: (str, str, Union[int, str], CephContainer, int, int, Optional[str], Optional[str], Optional[str]) -> None - if daemon_type == 'mon' and not os.path.exists( - get_data_dir(fsid, 'mon', daemon_id)): + osd_fsid=None, + reconfig=False): + # type: (str, str, Union[int, str], CephContainer, int, int, Optional[str], Optional[str], Optional[str], Optional[bool]) -> None + data_dir = get_data_dir(fsid, daemon_type, daemon_id) + if reconfig and not os.path.exists(data_dir): + raise Error('cannot reconfig, data path %s does not exist' % data_dir) + if daemon_type == 'mon' and not os.path.exists(data_dir): assert config assert keyring # tmp keyring file @@ -973,9 +977,9 @@ def deploy_daemon(fsid, daemon_type, daemon_id, c, uid, gid, fsid, daemon_type, daemon_id, uid, gid, config, keyring) - - deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, - osd_fsid=osd_fsid) + if not reconfig: + deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, + osd_fsid=osd_fsid) update_firewalld(daemon_type) def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, @@ -1723,9 +1727,10 @@ def command_deploy(): c = get_container(args.fsid, daemon_type, daemon_id) deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid, config, keyring, - osd_fsid=args.osd_fsid) + osd_fsid=args.osd_fsid, + reconfig=args.reconfig) - if crash_keyring: + if crash_keyring and not args.reconfig: deploy_crash(args.fsid, uid, gid, config, crash_keyring) else: # monitoring daemon - prometheus, grafana, alertmanager @@ -1758,7 +1763,8 @@ def command_deploy(): raise Error("{} not implemented in command_deploy function".format(daemon_type)) c = get_container(args.fsid, daemon_type, daemon_id, container_args=monitoring_args) - deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid) + deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid, + reconfig=args.reconfig) ################################## @@ -2552,6 +2558,10 @@ def _get_parser(): '--skip-firewalld', action='store_true', help='Do not configure firewalld') + parser_deploy.add_argument( + '--reconfig', + action='store_true', + help='Reconfigure a previously deployed daemon') parser_check_host = subparsers.add_parser( 'check-host', help='check host configuration') -- 2.39.5