From d962cc96cd0a425e93d15ad7fd7aaac9c7a2ea28 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Mon, 4 Nov 2024 15:35:02 +0100 Subject: [PATCH] Add support to configure which systemd unit services or targets to use Signed-off-by: Tobias Wolf --- README.md | 10 +++--- config.example.osism.yaml | 1 - config.example.yaml | 6 ++++ src/rookify/config.schema.yaml | 8 +++++ src/rookify/modules/ceph.py | 43 ++++++++++++++++++++++++ src/rookify/modules/migrate_mds/main.py | 5 ++- src/rookify/modules/migrate_mgrs/main.py | 5 ++- src/rookify/modules/migrate_mons/main.py | 5 ++- src/rookify/modules/migrate_osds/main.py | 4 ++- src/rookify/modules/migrate_rgws/main.py | 5 ++- 10 files changed, 82 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 99656ec..8a0df87 100644 --- a/README.md +++ b/README.md @@ -103,17 +103,19 @@ OSD devices: Not analyzed yet #### Troubleshooting -**ssh-issues:** -- make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\ Any: return getattr(self.__ceph, name) @@ -32,6 +39,42 @@ def _json_command(self, handler: Any, *args: Any) -> Any: return data + def get_systemd_mds_file_name(self, host: str) -> str: + return self._get_systemd_template_file_name( + self._systemd_file_name_templates.get("mds", "ceph-mds.target"), + host, + ) + + def get_systemd_mgr_file_name(self, host: str) -> str: + return self._get_systemd_template_file_name( + self._systemd_file_name_templates.get("mgr", "ceph-mgr.target"), + host, + ) + + def get_systemd_mon_file_name(self, host: str) -> str: + return self._get_systemd_template_file_name( + self._systemd_file_name_templates.get("mon", "ceph-mon.target"), + host, + ) + + def get_systemd_osd_file_name(self, host: str, osd_id: int) -> str: + file_name_template: str = self._systemd_file_name_templates.get( + "osd", "ceph-osd@{0:d}.service".format(osd_id) + ) + + return file_name_template.format(fsid=self._fsid, host=host, osd_id=osd_id) + + def get_systemd_rgw_file_name(self, host: str) -> str: + return self._get_systemd_template_file_name( + self._systemd_file_name_templates.get("mon", "ceph-radosgw.target"), + host, + ) + + def _get_systemd_template_file_name( + self, file_name_template: str, host: str + ) -> str: + return file_name_template.format(fsid=self._fsid, host=host) + def get_osd_pool_configurations_from_map( self, dump_data: Dict[str, Any] ) -> Dict[str, Any]: diff --git a/src/rookify/modules/migrate_mds/main.py b/src/rookify/modules/migrate_mds/main.py index 163bc56..d9f7694 100644 --- a/src/rookify/modules/migrate_mds/main.py +++ b/src/rookify/modules/migrate_mds/main.py @@ -83,7 +83,10 @@ def execute(self) -> None: def _disable_mds(self, mds_host: str) -> None: result = self.ssh.command( - mds_host, "sudo systemctl disable --now ceph-mds.target" + mds_host, + "sudo systemctl disable --now {0}".format( + self.ceph.get_systemd_mds_file_name(mds_host) + ), ) if result.failed: diff --git a/src/rookify/modules/migrate_mgrs/main.py b/src/rookify/modules/migrate_mgrs/main.py index 8dce03e..9803975 100644 --- a/src/rookify/modules/migrate_mgrs/main.py +++ b/src/rookify/modules/migrate_mgrs/main.py @@ -44,7 +44,10 @@ def _migrate_mgr(self, mgr_host: str) -> None: self.logger.info("Migrating ceph-mgr daemon at host'{0}'".format(mgr_host)) result = self.ssh.command( - mgr_host, "sudo systemctl disable --now ceph-mgr.target" + mgr_host, + "sudo systemctl disable --now {0}".format( + self.ceph.get_systemd_mgr_file_name(mgr_host) + ), ) if result.failed: diff --git a/src/rookify/modules/migrate_mons/main.py b/src/rookify/modules/migrate_mons/main.py index 92e08a0..f3e425e 100644 --- a/src/rookify/modules/migrate_mons/main.py +++ b/src/rookify/modules/migrate_mons/main.py @@ -51,7 +51,10 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: self.logger.info("Migrating ceph-mon daemon '{0}'".format(mon["name"])) result = self.ssh.command( - mon["name"], "sudo systemctl disable --now ceph-mon.target" + mon["name"], + "sudo systemctl disable --now {0}".format( + self.ceph.get_systemd_mon_file_name(mon["name"]) + ), ) if result.failed: diff --git a/src/rookify/modules/migrate_osds/main.py b/src/rookify/modules/migrate_osds/main.py index aa743d9..d2212b9 100644 --- a/src/rookify/modules/migrate_osds/main.py +++ b/src/rookify/modules/migrate_osds/main.py @@ -158,7 +158,9 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: result = self.ssh.command( host, - "sudo systemctl disable --now ceph-osd@{0:d}.service".format(osd_id), + "sudo systemctl disable --now {0}".format( + self.ceph.get_systemd_osd_file_name(host, osd_id) + ), ) if result.failed: diff --git a/src/rookify/modules/migrate_rgws/main.py b/src/rookify/modules/migrate_rgws/main.py index fc11c55..aaa4e25 100644 --- a/src/rookify/modules/migrate_rgws/main.py +++ b/src/rookify/modules/migrate_rgws/main.py @@ -78,7 +78,10 @@ def _migrate_rgw(self, rgw_host: str) -> None: if is_migration_required: result = self.ssh.command( - rgw_host, "sudo systemctl disable --now ceph-radosgw.target" + rgw_host, + "sudo systemctl disable --now {0}".format( + self.ceph.get_systemd_rgw_file_name(rgw_host) + ), ) if result.failed: