]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add --reconfig option for 'deploy'
authorSage Weil <sage@redhat.com>
Mon, 16 Dec 2019 21:16:13 +0000 (15:16 -0600)
committerSage Weil <sage@redhat.com>
Sun, 22 Dec 2019 16:50:23 +0000 (10:50 -0600)
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 <sage@redhat.com>
src/cephadm/cephadm

index 8e5eacf002fce088d21c1af2c05411b8d2979e80..d3ce18df718969b279b708b69cd44b4314eabbb5 100755 (executable)
@@ -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')