From 3b28df83624fbd0eaa7168ecbef3c60dac9b89d6 Mon Sep 17 00:00:00 2001 From: Adam King Date: Thu, 9 Jan 2025 11:36:34 -0500 Subject: [PATCH] cephadm: fix handling of ceph-exporter sock-dir Fixes: https://tracker.ceph.com/issues/69475 It turns out the sock-dir for ceph-exporter only needs to exist within the container, not on the host. Previous code, including the validation function this commit removes and previous patches trying to fix the ceph-exporter asok file not appearing on the host, were all done assuming it mattered what was on the host. This patch changes things so all we do with the sock dir is mount it to /var/run/ceph/ and don't worry about whether that dir exists on the host. Additionally, the patch makes it so /var/run/ceph/ is created during ceph-exporter deployment. Signed-off-by: Adam King --- src/cephadm/cephadmlib/daemons/ceph.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/cephadm/cephadmlib/daemons/ceph.py b/src/cephadm/cephadmlib/daemons/ceph.py index cf26e017164..e29bf127e0b 100644 --- a/src/cephadm/cephadmlib/daemons/ceph.py +++ b/src/cephadm/cephadmlib/daemons/ceph.py @@ -343,13 +343,9 @@ class CephExporter(ContainerDaemonForm): ) return args - def validate(self) -> None: - if not os.path.isdir(self.sock_dir): - raise Error( - f'Desired sock dir for ceph-exporter is not directory: {self.sock_dir}' - ) - def container(self, ctx: CephadmContext) -> CephContainer: + uid, gid = self.uid_gid(ctx) + make_run_dir(ctx.fsid, uid, gid) ctr = daemon_to_container(ctx, self) return to_deployment_container(ctx, ctr) @@ -366,6 +362,9 @@ class CephExporter(ContainerDaemonForm): ) -> None: cm = Ceph.get_ceph_mounts(ctx, self.identity) mounts.update(cm) + # we want to always mount /var/run/ceph/ to the sock + # dir within the container. See https://tracker.ceph.com/issues/69475 + mounts.update({f'/var/run/ceph/{ctx.fsid}': self.sock_dir}) if self.https_enabled: data_dir = self.identity.data_dir(ctx.data_dir) mounts.update({os.path.join(data_dir, 'etc/certs'): '/etc/certs'}) @@ -390,13 +389,6 @@ class CephExporter(ContainerDaemonForm): def default_entrypoint(self) -> str: return self.entrypoint - def prepare_data_dir(self, data_dir: str, uid: int, gid: int) -> None: - if not os.path.exists(self.sock_dir): - os.mkdir(self.sock_dir) - # part of validation is for the sock dir, so we postpone - # it until now - self.validate() - def create_daemon_dirs(self, data_dir: str, uid: int, gid: int) -> None: """Create files under the container data dir""" if not os.path.isdir(data_dir): -- 2.39.5