From: Timothy Q Nguyen Date: Sat, 6 Dec 2025 02:07:19 +0000 (-0800) Subject: src/cephadm: updated crash dir creation X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=416383038cba0a9296b42eb3e58b33917bc60ebe;p=ceph.git src/cephadm: updated crash dir creation This change is meant to address the issue of daemons like grafana changing the uid and gid of the crash directory, /var/lib/ceph/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 --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 4e255e551656..81524574c6fc 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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 diff --git a/src/cephadm/cephadmlib/daemons/__init__.py b/src/cephadm/cephadmlib/daemons/__init__.py index bdf2c532e02d..601992ef3947 100644 --- a/src/cephadm/cephadmlib/daemons/__init__.py +++ b/src/cephadm/cephadmlib/daemons/__init__.py @@ -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', diff --git a/src/cephadm/cephadmlib/daemons/ceph.py b/src/cephadm/cephadmlib/daemons/ceph.py index ac16bbebcfcc..a4b10487b37f 100644 --- a/src/cephadm/cephadmlib/daemons/ceph.py +++ b/src/cephadm/cephadmlib/daemons/ceph.py @@ -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):