]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: fix handling of ceph-exporter sock-dir
authorAdam King <adking@redhat.com>
Thu, 9 Jan 2025 16:36:34 +0000 (11:36 -0500)
committerAdam King <adking@redhat.com>
Mon, 13 Jan 2025 18:28:05 +0000 (13:28 -0500)
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/<fsid>
and don't worry about whether that dir exists on the host.
Additionally, the patch makes it so /var/run/ceph/<fsid> is
created during ceph-exporter deployment.

Signed-off-by: Adam King <adking@redhat.com>
src/cephadm/cephadmlib/daemons/ceph.py

index cf26e0171648c9ca62b2996513e1dfb6e8013f70..e29bf127e0bc22154c1e43076317df28c15b7ec5 100644 (file)
@@ -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/<fsid> 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):