]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: create ceph-exporter sock dir if it's not present
authorAdam King <adking@redhat.com>
Mon, 19 Feb 2024 16:14:11 +0000 (11:14 -0500)
committerAdam King <adking@redhat.com>
Wed, 21 Feb 2024 13:41:42 +0000 (08:41 -0500)
Since this is usually /var/run/ceph/ which ends up getting
created by other daemons as well, it was common to see
ceph-exporter fail to deploy and then deploy fine after
once other daemons were down on the host. I don't see any
reason we can't just try to make the directory here instead
of bailing out.

Fixes: https://tracker.ceph.com/issues/64491wq
Signed-off-by: Adam King <adking@redhat.com>
src/cephadm/cephadmlib/daemons/ceph.py

index 0afb8f734af5fd3003e110dd7ec6a0ea3ead1a71..45562fe4fdd47205beedcdb61ab377be64fb703b 100644 (file)
@@ -299,8 +299,6 @@ class CephExporter(ContainerDaemonForm):
         self.prio_limit = config_json.get('prio-limit', 5)
         self.stats_period = config_json.get('stats-period', 5)
 
-        self.validate()
-
     @classmethod
     def init(
         cls, ctx: CephadmContext, fsid: str, daemon_id: Union[int, str]
@@ -329,7 +327,7 @@ class CephExporter(ContainerDaemonForm):
 
     def validate(self) -> None:
         if not os.path.isdir(self.sock_dir):
-            raise Error(f'Directory does not exist. Got: {self.sock_dir}')
+            raise Error(f'Desired sock dir for ceph-exporter is not directory: {self.sock_dir}')
 
     def container(self, ctx: CephadmContext) -> CephContainer:
         ctr = daemon_to_container(ctx, self)
@@ -369,6 +367,13 @@ 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 get_ceph_mounts_for_type(
     ctx: CephadmContext, fsid: str, daemon_type: str