]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-daemon: simplify uid/gid a bit
authorSage Weil <sage@redhat.com>
Fri, 27 Sep 2019 14:48:32 +0000 (09:48 -0500)
committerSage Weil <sage@redhat.com>
Wed, 2 Oct 2019 12:11:12 +0000 (07:11 -0500)
Assume user ceph and group ceph exist inside the container.  We still need
the uid/gid for creating daemon directories, though, and for the bootstrap,
where we are creating files on the host and passing them through.

Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-daemon

index a525dc77e32176f55f8ea3ac7c6f4042ec15eda3..9f4f5db1e4ae03c3c0d48fd28c676ce709d2fd71 100755 (executable)
@@ -41,14 +41,14 @@ def get_data_dir(base, fsid, t, n):
 def get_log_dir(base, fsid):
     return base + '/' + fsid
 
-def get_daemon_args(fsid, daemon_type, daemon_id, uid, gid):
+def get_daemon_args(fsid, daemon_type, daemon_id):
     r = [
         '--default-admin-socket', '/var/run/ceph/' + fsid + '-' + daemon_type + '.' + daemon_id + '.asok',
         '--default-log-to-file=false',
         '--default-log-to-stderr=true',
         ]
-    r += ['--setuser', str(uid)]
-    r += ['--setgroup', str(gid)]
+    r += ['--setuser', 'ceph']
+    r += ['--setgroup', 'ceph']
     return r
 
 def create_daemon_dirs(fsid, daemon_type, daemon_id, uid, gid,
@@ -93,7 +93,7 @@ def get_config_and_keyring():
             config = f.read()
     return (config, keyring)
 
-def get_container(fsid, daemon_type, daemon_id, uid, gid):
+def get_container(fsid, daemon_type, daemon_id):
     data_dir = get_data_dir(args.data_dir, fsid, daemon_type, daemon_id)
     log_dir = get_log_dir(args.log_dir, fsid)
 
@@ -116,7 +116,7 @@ def get_container(fsid, daemon_type, daemon_id, uid, gid):
         args=['-i', daemon_id,
               '-c', cdata_dir + '/conf',
               '-f', # foreground
-        ] + extra_args + get_daemon_args(fsid, daemon_type, daemon_id, uid, gid),
+        ] + extra_args + get_daemon_args(fsid, daemon_type, daemon_id),
         volume_mounts=mounts,
         dname=daemon_type + '.' + daemon_id,
         cname='ceph-%s-%s.%s' % (fsid, daemon_type, daemon_id),
@@ -368,7 +368,7 @@ def command_bootstrap():
               '--monmap', '/tmp/monmap',
               '--keyring', '/tmp/keyring',
               '--debug-mon', '20',
-              ] + get_daemon_args(fsid, 'mon', mon_id, uid, gid),
+              ] + get_daemon_args(fsid, 'mon', mon_id),
         volume_mounts={
             log_dir: '/var/log/ceph:z',
             mon_dir: '/var/lib/ceph/mon/ceph-%s:z' % (mon_id),
@@ -380,12 +380,12 @@ def command_bootstrap():
     with open(mon_dir + '/conf', 'w') as f:
         f.write(config)
 
-    mon_c = get_container(fsid, 'mon', mon_id, uid, gid)
+    mon_c = get_container(fsid, 'mon', mon_id)
     deploy_daemon(fsid, 'mon', mon_id, mon_c, uid, gid)
 
     # create mgr
     mgr_keyring = '[mgr.%s]\n\tkey = %s\n' % (mgr_id, mgr_key)
-    mgr_c = get_container(fsid, 'mgr', mgr_id, uid, gid)
+    mgr_c = get_container(fsid, 'mgr', mgr_id)
     deploy_daemon(fsid, 'mgr', mgr_id, mgr_c, uid, gid, config, mgr_keyring)
 
     # output files
@@ -410,7 +410,7 @@ def command_deploy():
         raise RuntimeError('daemon type %s not recognized' % daemon_type)
     (config, keyring) = get_config_and_keyring()
     (uid, gid) = extract_uid_gid()
-    c = get_container(args.fsid, daemon_type, daemon_id, uid, gid)
+    c = get_container(args.fsid, daemon_type, daemon_id)
     deploy_daemon(args.fsid, daemon_type, daemon_id, c, uid, gid,
                   config, keyring)
 
@@ -419,7 +419,7 @@ def command_deploy():
 def command_run():
     (daemon_type, daemon_id) = args.name.split('.')
     (uid, gid) = extract_uid_gid()
-    c = get_container(args.fsid, daemon_type, daemon_id, uid, gid)
+    c = get_container(args.fsid, daemon_type, daemon_id)
     c.run()