From 05630fb9f5ac4a7b918181decc5c77f5c990c8fe Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Wed, 7 Oct 2020 13:37:59 -0600 Subject: [PATCH] cephadm: mount RGW keyring in NFS container Fixes: https://tracker.ceph.com/issues/43686 Signed-off-by: Michael Fritch (cherry picked from commit 53c6388c5774a2fd10e2ab5a23963698a5a0e336) --- src/cephadm/cephadm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index d222f57db2356..b770ca8b94878 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -242,6 +242,7 @@ class NFSGanesha(object): self.userid = dict_get(config_json, 'userid') self.extra_args = dict_get(config_json, 'extra_args', []) self.files = dict_get(config_json, 'files', {}) + self.rgw = dict_get(config_json, 'rgw', {}) # validate the supplied args self.validate() @@ -251,13 +252,17 @@ class NFSGanesha(object): # type: (str, Union[int, str]) -> NFSGanesha return cls(fsid, daemon_id, get_parm(args.config_json), args.image) - @staticmethod - def get_container_mounts(data_dir): + def get_container_mounts(self, data_dir): # type: (str) -> Dict[str, str] mounts = dict() mounts[os.path.join(data_dir, 'config')] = '/etc/ceph/ceph.conf:z' mounts[os.path.join(data_dir, 'keyring')] = '/etc/ceph/keyring:z' mounts[os.path.join(data_dir, 'etc/ganesha')] = '/etc/ganesha:z' + if self.rgw: + cluster = self.rgw.get('cluster', 'ceph') + rgw_user = self.rgw.get('user', 'admin') + mounts[os.path.join(data_dir, 'keyring.rgw')] = \ + '/var/lib/ceph/radosgw/%s-%s/keyring:z' % (cluster, rgw_user) return mounts @staticmethod @@ -296,6 +301,13 @@ class NFSGanesha(object): if fname not in self.files: raise Error('required file missing from config-json: %s' % fname) + # check for an RGW config + if self.rgw: + if not self.rgw.get('keyring'): + raise Error('RGW keyring is missing') + if not self.rgw.get('user'): + raise Error('RGW user is missing') + def get_daemon_name(self): # type: () -> str return '%s.%s' % (self.daemon_type, self.daemon_id) @@ -333,6 +345,14 @@ class NFSGanesha(object): os.fchmod(f.fileno(), 0o600) f.write(config_content) + # write the RGW keyring + if self.rgw: + keyring_path = os.path.join(data_dir, 'keyring.rgw') + with open(keyring_path, 'w') as f: + os.fchmod(f.fileno(), 0o600) + os.fchown(f.fileno(), uid, gid) + f.write(self.rgw.get('keyring', '')) + def get_rados_grace_container(self, action): # type: (str) -> CephContainer """Container for a ganesha action on the grace db""" @@ -1934,7 +1954,8 @@ def get_container_mounts(fsid, daemon_type, daemon_id, if daemon_type == NFSGanesha.daemon_type: assert daemon_id data_dir = get_data_dir(fsid, daemon_type, daemon_id) - mounts.update(NFSGanesha.get_container_mounts(data_dir)) + nfs_ganesha = NFSGanesha.init(fsid, daemon_id) + mounts.update(nfs_ganesha.get_container_mounts(data_dir)) if daemon_type == CephIscsi.daemon_type: assert daemon_id -- 2.39.5