]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/cephadm: updated crash dir creation
authorTimothy Q Nguyen <timqn22@gmail.com>
Sat, 6 Dec 2025 02:07:19 +0000 (18:07 -0800)
committerTimothy Q Nguyen <timqn22@gmail.com>
Tue, 6 Jan 2026 21:22:15 +0000 (13:22 -0800)
This change is meant to address the issue of daemons like
grafana changing the uid and gid of the crash directory,
/var/lib/ceph<fsid>/crash, the crash service only works if
this directory has the standard ceph-user uid and gid. I've
created a Crash class based on the Ceph class and overwrite
the create function. Now, the directories will be made just
before the Crash daemon is created. The directories have to
be made before the Crash daemon for the service to check
properly.

Signed-off-by: Timothy Q Nguyen <timqn22@gmail.com>
src/cephadm/cephadm.py
src/cephadm/cephadmlib/daemons/__init__.py
src/cephadm/cephadmlib/daemons/ceph.py

index 4e255e551656bf9e793c3bfa7916937c0730adf9..81524574c6fc8f8f05fd043595a655b5643bcdc0 100755 (executable)
@@ -475,9 +475,6 @@ def make_data_dir_base(fsid, data_dir, uid, gid):
     # type: (str, str, int, int) -> str
     data_dir_base = os.path.join(data_dir, fsid)
     makedirs(data_dir_base, uid, gid, DATA_DIR_MODE)
-    makedirs(os.path.join(data_dir_base, 'crash'), uid, gid, DATA_DIR_MODE)
-    makedirs(os.path.join(data_dir_base, 'crash', 'posted'), uid, gid,
-             DATA_DIR_MODE)
     return data_dir_base
 
 
index bdf2c532e02d6ec77494262f6854b0b103e21680..601992ef39471c56d728a39bf2baf54e871075cd 100644 (file)
@@ -1,4 +1,4 @@
-from .ceph import Ceph, OSD, CephExporter
+from .ceph import Ceph, OSD, CephExporter, Crash
 from .custom import CustomContainer
 from .ingress import HAproxy, Keepalived
 from .iscsi import CephIscsi
@@ -15,6 +15,7 @@ from .oauth2_proxy import OAuth2Proxy
 __all__ = [
     'Ceph',
     'CephExporter',
+    'Crash',
     'CephIscsi',
     'CephNvmeof',
     'CustomContainer',
index ac16bbebcfcc9525998e8d8733b389a1ed6ccd72..a4b10487b37f1d068b6a923376bd9a8e12c86688 100644 (file)
@@ -12,7 +12,10 @@ from ..context_getters import (
 )
 from ..daemon_form import register as register_daemon_form
 from ..daemon_identity import DaemonIdentity
-from ..constants import DEFAULT_IMAGE
+from ..constants import (
+    DEFAULT_IMAGE,
+    DATA_DIR_MODE,
+)
 from ..context import CephadmContext
 from ..deployment_utils import to_deployment_container
 from ..exceptions import Error
@@ -49,7 +52,7 @@ class Ceph(ContainerDaemonForm):
     @classmethod
     def for_daemon_type(cls, daemon_type: str) -> bool:
         # TODO: figure out a way to un-special-case osd
-        return daemon_type in cls._daemons and daemon_type != 'osd'
+        return daemon_type in cls._daemons and daemon_type not in ('osd', 'crash')
 
     def __init__(self, ctx: CephadmContext, ident: DaemonIdentity) -> None:
         self.ctx = ctx
@@ -332,6 +335,27 @@ class OSD(Ceph):
     def osd_fsid(self) -> Optional[str]:
         return self._osd_fsid
 
+@register_daemon_form
+class Crash(Ceph):
+    @classmethod
+    def for_daemon_type(cls, daemon_type: str) -> bool:
+        return daemon_type == 'crash'
+
+    def __init__(
+        self,
+        ctx: CephadmContext,
+        ident: DaemonIdentity,
+    ) -> None:
+        super().__init__(ctx, ident)
+
+    @classmethod
+    def create(cls, ctx: CephadmContext, ident: DaemonIdentity) -> 'Ceph':
+        (uid, gid) = extract_uid_gid(ctx)
+        data_dir_base = f'{ctx.data_dir}/{ident.fsid}'
+        makedirs(os.path.join(data_dir_base, 'crash'), uid, gid, DATA_DIR_MODE)
+        makedirs(os.path.join(data_dir_base, 'crash', 'posted'), uid, gid,
+                 DATA_DIR_MODE)
+        return cls(ctx, ident)
 
 @register_daemon_form
 class CephExporter(ContainerDaemonForm):