From 87c807644787e9a14b8bedc3ea3307a61ba90330 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Wed, 28 Aug 2024 23:08:38 +0200 Subject: [PATCH] Improve logging Signed-off-by: Tobias Wolf --- src/rookify/modules/migrate_mds/main.py | 20 +++++++------ src/rookify/modules/migrate_mds_pools/main.py | 6 ++-- src/rookify/modules/migrate_mgrs/main.py | 16 +++++------ src/rookify/modules/migrate_mons/main.py | 22 ++++++++------- src/rookify/modules/migrate_osd_pools/main.py | 4 +-- src/rookify/modules/migrate_osds/main.py | 28 +++++++++++-------- src/rookify/modules/migrate_rgw_pools/main.py | 6 ++-- src/rookify/modules/migrate_rgws/main.py | 28 ++++++++++--------- 8 files changed, 72 insertions(+), 58 deletions(-) diff --git a/src/rookify/modules/migrate_mds/main.py b/src/rookify/modules/migrate_mds/main.py index 973886b..05b1c29 100644 --- a/src/rookify/modules/migrate_mds/main.py +++ b/src/rookify/modules/migrate_mds/main.py @@ -25,7 +25,7 @@ def preflight(self) -> None: for mds_host, mds_daemons in state_data["node"]["ls"]["mds"].items(): if len(mds_daemons) > 1: raise ModuleException( - "There are more than 1 Ceph MDS daemons running on host {0}".format( + "There are more than 1 ceph-mds daemons running on host {0}".format( mds_host ) ) @@ -51,7 +51,7 @@ def execute(self) -> None: if mds_host in migrated_mds: continue - self.logger.debug("Migrating Ceph MDS daemon '{0}'".format(mds_host)) + self.logger.info("Migrating ceph-mds daemon at host '{0}'".format(mds_host)) if ( is_migration_required @@ -88,13 +88,13 @@ def _disable_mds(self, mds_host: str) -> None: if result.failed: raise ModuleException( - "Disabling original Ceph MDS daemon at host {0} failed: {1}".format( + "Disabling original ceph-mds daemon at host {0} failed: {1}".format( mds_host, result.stderr ) ) self.logger.debug( - "Waiting for disabled original Ceph MDS daemon '{0}' to disconnect".format( + "Waiting for disabled original ceph-mds daemon at host '{0}' to disconnect".format( mds_host ) ) @@ -107,7 +107,7 @@ def _disable_mds(self, mds_host: str) -> None: sleep(2) - self.logger.info("Disabled Ceph MDS daemon '{0}'".format(mds_host)) + self.logger.info("Disabled ceph-mds daemon at host '{0}'".format(mds_host)) def _set_mds_label(self, mds_host: str) -> None: node_patch = {"metadata": {"labels": {self.k8s.mds_placement_label: "true"}}} @@ -117,12 +117,14 @@ def _set_mds_label(self, mds_host: str) -> None: not in self.k8s.core_v1_api.patch_node(mds_host, node_patch).metadata.labels ): raise ModuleException( - "Failed to patch k8s node for Ceph MDS daemon '{0}'".format(mds_host) + "Failed to patch k8s for ceph-mds daemon node '{0}'".format(mds_host) ) def _enable_rook_based_mds(self, mds_host: str) -> None: self.logger.debug( - "Enabling and waiting for Rook based MDS daemon '{0}'".format(mds_host) + "Enabling and waiting for Rook based ceph-mds daemon node '{0}'".format( + mds_host + ) ) while True: @@ -133,7 +135,9 @@ def _enable_rook_based_mds(self, mds_host: str) -> None: sleep(2) - self.logger.debug("Rook based MDS daemon '{0}' available".format(mds_host)) + self.logger.info( + "Rook based ceph-mds daemon node '{0}' available".format(mds_host) + ) @staticmethod def register_execution_state( diff --git a/src/rookify/modules/migrate_mds_pools/main.py b/src/rookify/modules/migrate_mds_pools/main.py index e9c3713..8a796dd 100644 --- a/src/rookify/modules/migrate_mds_pools/main.py +++ b/src/rookify/modules/migrate_mds_pools/main.py @@ -22,7 +22,7 @@ def preflight(self) -> None: for mds_fs_data in state_data["fs"]["ls"]: if not mds_fs_data["metadata_pool"].endswith("-metadata"): self.logger.warn( - "MDS filesystem '{0}' uses an incompatible Ceph pool metadata name '{1}' and can not be migrated to Rook automatically".format( + "ceph-mds filesystem '{0}' uses an incompatible pool metadata name '{1}' and can not be migrated to Rook automatically".format( mds_fs_data["name"], mds_fs_data["metadata_pool"] ) ) @@ -84,7 +84,7 @@ def _migrate_pool(self, pool: Dict[str, Any]) -> None: state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data - self.logger.debug("Migrating Ceph MDS pool '{0}'".format(pool["name"])) + self.logger.info("Migrating ceph-mds pool '{0}'".format(pool["name"])) osd_pool_configurations = pool["osd_pool_configurations"] pool_metadata_osd_configuration = osd_pool_configurations[pool["metadata"]] @@ -142,7 +142,7 @@ def _migrate_pool(self, pool: Dict[str, Any]) -> None: "MigrateMdsPoolsHandler" ).migrated_pools = migrated_pools - self.logger.info("Migrated Ceph MDS pool '{0}'".format(pool["name"])) + self.logger.info("Migrated ceph-mds pool '{0}'".format(pool["name"])) @staticmethod def register_execution_state( diff --git a/src/rookify/modules/migrate_mgrs/main.py b/src/rookify/modules/migrate_mgrs/main.py index 30f1f95..1717087 100644 --- a/src/rookify/modules/migrate_mgrs/main.py +++ b/src/rookify/modules/migrate_mgrs/main.py @@ -32,7 +32,7 @@ def _migrate_mgr(self, mgr_host: str) -> None: if mgr_host in migrated_mgrs: return - self.logger.debug("Migrating Ceph mgr daemon '{0}'".format(mgr_host)) + 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" @@ -40,13 +40,13 @@ def _migrate_mgr(self, mgr_host: str) -> None: if result.failed: raise ModuleException( - "Disabling original Ceph mgr daemon at host {0} failed: {1}".format( + "Disabling original ceph-mgr daemon at host {0} failed: {1}".format( mgr_host, result.stderr ) ) self.logger.debug( - "Waiting for disabled original Ceph mgr daemon '{0}' to disconnect".format( + "Waiting for disabled original ceph-mgr daemon '{0}' to disconnect".format( mgr_host ) ) @@ -60,7 +60,7 @@ def _migrate_mgr(self, mgr_host: str) -> None: sleep(2) self.logger.info( - "Disabled Ceph mgr daemon '{0}' and enabling Rook based Ceph mgr daemon '{0}'".format( + "Disabled ceph-mgr daemon '{0}' and enabling Rook based daemon".format( mgr_host ) ) @@ -72,7 +72,7 @@ def _migrate_mgr(self, mgr_host: str) -> None: not in self.k8s.core_v1_api.patch_node(mgr_host, node_patch).metadata.labels ): raise ModuleException( - "Failed to patch k8s node for Ceph mgr daemon '{0}'".format(mgr_host) + "Failed to patch k8s for ceph-mgr daemon node '{0}'".format(mgr_host) ) migrated_mgrs.append(mgr_host) @@ -86,7 +86,7 @@ def _migrate_mgr(self, mgr_host: str) -> None: ) self.logger.debug( - "Waiting for {0:d} Ceph mgr daemons to be available".format( + "Waiting for {0:d} ceph-mgr daemons to be available".format( mgr_count_expected ) ) @@ -98,8 +98,8 @@ def _migrate_mgr(self, mgr_host: str) -> None: sleep(2) - self.logger.debug( - "{0:d} Ceph mgr daemons are available".format(mgr_count_expected) + self.logger.info( + "{0:d} ceph-mgr daemons are available".format(mgr_count_expected) ) @staticmethod diff --git a/src/rookify/modules/migrate_mons/main.py b/src/rookify/modules/migrate_mons/main.py index 8665c9f..596ddb8 100644 --- a/src/rookify/modules/migrate_mons/main.py +++ b/src/rookify/modules/migrate_mons/main.py @@ -39,7 +39,7 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: if mon["name"] in migrated_mons: return - self.logger.debug("Migrating Ceph mon daemon '{0}'".format(mon["name"])) + self.logger.info("Migrating ceph-mon daemon '{0}'".format(mon["name"])) result = self.ssh.command( mon["name"], "sudo systemctl disable --now ceph-mon.target" @@ -47,13 +47,13 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: if result.failed: raise ModuleException( - "Disabling original Ceph mon daemon at host {0} failed: {1}".format( + "Disabling original ceph-mon daemon {0} failed: {1}".format( mon["name"], result.stderr ) ) self.logger.debug( - "Waiting for disabled original Ceph mon daemon '{0}' to disconnect".format( + "Waiting for disabled original ceph-mon daemon '{0}' to disconnect".format( mon["name"] ) ) @@ -69,12 +69,12 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: sleep(2) - self.logger.info("Disabled Ceph mon daemon '{0}'".format(mon["name"])) + self.logger.info("Disabled ceph-mon daemon '{0}'".format(mon["name"])) self.ceph.mon_command("mon remove", name=mon["name"]) - self.logger.info( - "Enabling Rook based Ceph mon daemon '{0}'".format(mon["name"]) + self.logger.debug( + "Enabling Rook based ceph-mon daemon at node '{0}'".format(mon["name"]) ) node_patch = {"metadata": {"labels": {self.k8s.mon_placement_label: "true"}}} @@ -86,7 +86,9 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: ).metadata.labels ): raise ModuleException( - "Failed to patch k8s node for Ceph mon daemon '{0}'".format(mon["name"]) + "Failed to patch k8s for ceph-mon daemon at node '{0}'".format( + mon["name"] + ) ) migrated_mons.append(mon["name"]) @@ -100,7 +102,7 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: ) self.logger.debug( - "Waiting for a quorum of {0:d} Ceph mon daemons".format(mon_count_expected) + "Waiting for a quorum of {0:d} ceph-mon daemons".format(mon_count_expected) ) while True: @@ -110,8 +112,8 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None: sleep(2) - self.logger.debug( - "Quorum of {0:d} Ceph mon daemons successful".format(mon_count_expected) + self.logger.info( + "Quorum of {0:d} ceph-mon daemons successful".format(mon_count_expected) ) @staticmethod diff --git a/src/rookify/modules/migrate_osd_pools/main.py b/src/rookify/modules/migrate_osd_pools/main.py index 67375bf..eafe828 100644 --- a/src/rookify/modules/migrate_osd_pools/main.py +++ b/src/rookify/modules/migrate_osd_pools/main.py @@ -49,7 +49,7 @@ def _migrate_pool(self, pool: Dict[str, Any]) -> None: if pool["pool_name"] in migrated_pools: return - self.logger.debug("Migrating Ceph OSD pool '{0}'".format(pool["pool_name"])) + self.logger.info("Migrating ceph-osd pool '{0}'".format(pool["pool_name"])) pool_definition_values = { "cluster_namespace": self._config["rook"]["cluster"]["namespace"], @@ -75,7 +75,7 @@ def _migrate_pool(self, pool: Dict[str, Any]) -> None: "MigrateOSDPoolsHandler" ).migrated_pools = migrated_pools - self.logger.info("Migrated Ceph OSD pool '{0}'".format(pool["pool_name"])) + self.logger.info("Migrated ceph-osd pool '{0}'".format(pool["pool_name"])) @staticmethod def register_execution_state( diff --git a/src/rookify/modules/migrate_osds/main.py b/src/rookify/modules/migrate_osds/main.py index cbbaa7f..f86914e 100644 --- a/src/rookify/modules/migrate_osds/main.py +++ b/src/rookify/modules/migrate_osds/main.py @@ -42,6 +42,10 @@ def _get_devices_of_hosts(self) -> Dict[str, Dict[str, str]]: if osd_id not in osd_devices[osd_host]: osd_devices[osd_host][osd_id] = osd_device_path + self.logger.debug( + "Analyzed {0:d} Ceph OSD(s) on host '{1}'".format(len(osds), osd_host) + ) + return osd_devices def _get_nodes_osd_devices(self, osd_ids: List[str]) -> List[Dict[str, Any]]: @@ -93,7 +97,7 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: "MigrateOSDsHandler", "migrated_osd_ids", default_value=[] ) - self.logger.info("Migrating Ceph OSD host '{0}'".format(host)) + self.logger.info("Migrating ceph-osd host '{0}'".format(host)) node_patch = {"metadata": {"labels": {self.k8s.osd_placement_label: "true"}}} @@ -102,15 +106,15 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: not in self.k8s.core_v1_api.patch_node(host, node_patch).metadata.labels ): raise ModuleException( - "Failed to patch k8s node for Ceph OSD host '{0}'".format(host) + "Failed to patch k8s for ceph-osd node '{0}'".format(host) ) for osd_id in osd_ids: if osd_id in migrated_osd_ids: return - self.logger.info( - "Migrating Ceph OSD daemon '{0}@{1:d}'".format(host, osd_id) + self.logger.debug( + "Migrating ceph-osd daemon '{0}@{1:d}'".format(host, osd_id) ) result = self.ssh.command( @@ -120,13 +124,13 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: if result.failed: raise ModuleException( - "Disabling original Ceph OSD daemon '{0}@{1:d}' failed: {2}".format( + "Disabling original ceph-osd daemon '{0}@{1:d}' failed: {2}".format( host, osd_id, result.stderr ) ) self.logger.debug( - "Waiting for disabled original Ceph OSD daemon '{0}@{1:d}' to disconnect".format( + "Waiting for disabled original ceph-osd daemon '{0}@{1:d}' to disconnect".format( host, osd_id ) ) @@ -140,10 +144,10 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: sleep(2) self.logger.info( - "Disabled Ceph OSD daemon '{0}@{1:d}'".format(host, osd_id) + "Disabled ceph-osd daemon '{0}@{1:d}'".format(host, osd_id) ) - self.logger.info("Enabling Rook based Ceph OSD host '{0}'".format(host)) + self.logger.info("Enabling Rook based ceph-osd node '{0}'".format(host)) nodes_osd_devices = self._get_nodes_osd_devices(migrated_osd_ids + osd_ids) @@ -170,7 +174,9 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: for osd_id in osd_ids: self.logger.debug( - "Waiting for Rook based OSD daemon '{0}@{1:d}'".format(host, osd_id) + "Waiting for Rook based ceph-osd daemon '{0}@{1:d}'".format( + host, osd_id + ) ) while True: @@ -181,8 +187,8 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None: sleep(2) - self.logger.debug( - "Rook based OSD daemon '{0}@{1:d}' available".format(host, osd_id) + self.logger.info( + "Rook based ceph-osd daemon '{0}@{1:d}' available".format(host, osd_id) ) @staticmethod diff --git a/src/rookify/modules/migrate_rgw_pools/main.py b/src/rookify/modules/migrate_rgw_pools/main.py index 2fa6428..1040aa7 100644 --- a/src/rookify/modules/migrate_rgw_pools/main.py +++ b/src/rookify/modules/migrate_rgw_pools/main.py @@ -59,7 +59,7 @@ def preflight(self) -> None: if zone["osd_pools"][metadata_name].get("erasure_code_profile", "") != "": raise ModuleException( - "Ceph RGW metadata OSD pools must use replication for Rook" + "ceph-rgw metadata OSD pools must use replication for Rook" ) self.machine.get_preflight_state("MigrateRgwPoolsHandler").zones = zones @@ -81,7 +81,7 @@ def _migrate_zone(self, zone_name: str, zone_data: Dict[str, Any]) -> None: "MigrateRgwPoolsHandler", "migrated_pools", default_value=[] ) - self.logger.debug("Migrating Ceph RGW zone '{0}'".format(zone_name)) + self.logger.info("Migrating ceph-rgw zone '{0}'".format(zone_name)) osd_pools = zone_data["osd_pools"] @@ -129,7 +129,7 @@ def _migrate_zone(self, zone_name: str, zone_data: Dict[str, Any]) -> None: "MigrateRgwPoolsHandler" ).migrated_pools = migrated_pools - self.logger.info("Migrated Ceph RGW zone '{0}'".format(zone_name)) + self.logger.info("Migrated ceph-rgw zone '{0}'".format(zone_name)) @staticmethod def register_execution_state( diff --git a/src/rookify/modules/migrate_rgws/main.py b/src/rookify/modules/migrate_rgws/main.py index 7fea2f5..0a5d2ca 100644 --- a/src/rookify/modules/migrate_rgws/main.py +++ b/src/rookify/modules/migrate_rgws/main.py @@ -21,7 +21,7 @@ def _get_rgw_daemon_hosts(self) -> List[str]: for rgw_daemon in rgw_daemons.values(): if "metadata" not in rgw_daemon or "hostname" not in rgw_daemon["metadata"]: raise ModuleException( - "Unexpected Ceph rgw daemon metadata: {0}".format(rgw_daemon) + "Unexpected ceph-rgw daemon metadata: {0}".format(rgw_daemon) ) if rgw_daemon["metadata"]["hostname"] not in rgw_daemon_hosts: rgw_daemon_hosts.append(rgw_daemon["metadata"]["hostname"]) @@ -43,7 +43,7 @@ def preflight(self) -> None: for rgw_daemon_host in rgw_daemon_hosts: if rgw_daemon_host not in self._config["ssh"]["hosts"]: raise ModuleException( - "Unexpected Ceph rgw daemon found (no SSH config): {0}".format( + "Unexpected ceph-rgw daemon found (no SSH config): {0}".format( rgw_daemon_host ) ) @@ -61,7 +61,7 @@ def _migrate_rgw(self, rgw_host: str) -> None: if rgw_host in migrated_rgws: return - self.logger.debug("Migrating Ceph rgw daemon '{0}'".format(rgw_host)) + self.logger.info("Migrating ceph-rgw daemon at host '{0}'".format(rgw_host)) migrated_zones = self.machine.get_execution_state_data( "MigrateRgwPoolsHandler", "migrated_zones", default_value=[] @@ -75,13 +75,13 @@ def _migrate_rgw(self, rgw_host: str) -> None: if result.failed: raise ModuleException( - "Disabling original Ceph rgw daemon at host {0} failed: {1}".format( + "Disabling original ceph-rgw host {0} failed: {1}".format( rgw_host, result.stderr ) ) self.logger.debug( - "Waiting for disabled original Ceph rgw daemon '{0}' to disconnect".format( + "Waiting for disabled original ceph-rgw host '{0}' to disconnect".format( rgw_host ) ) @@ -94,11 +94,9 @@ def _migrate_rgw(self, rgw_host: str) -> None: sleep(2) - self.logger.info( - "Disabled Ceph rgw daemon '{0}' and enabling Rook based Ceph rgw daemon '{0}'".format( - rgw_host - ) - ) + self.logger.info("Disabled ceph-rgw host '{0}'".format(rgw_host)) + + self.logger.debug("Enabling Rook based ceph-rgw node '{0}'".format(rgw_host)) node_patch = {"metadata": {"labels": {self.k8s.rgw_placement_label: "true"}}} @@ -107,7 +105,7 @@ def _migrate_rgw(self, rgw_host: str) -> None: not in self.k8s.core_v1_api.patch_node(rgw_host, node_patch).metadata.labels ): raise ModuleException( - "Failed to patch k8s node for Ceph rgw daemon '{0}'".format(rgw_host) + "Failed to patch k8s node for ceph-rgw node '{0}'".format(rgw_host) ) migrated_rgws.append(rgw_host) @@ -118,7 +116,9 @@ def _migrate_rgw(self, rgw_host: str) -> None: if is_migration_required: self.logger.debug( - "Waiting for at least one Rook based rgw daemon '{0}'".format(rgw_host) + "Waiting for at least one Rook based RGW daemon for node '{0}'".format( + rgw_host + ) ) while True: @@ -129,7 +129,9 @@ def _migrate_rgw(self, rgw_host: str) -> None: sleep(2) - self.logger.debug("Rook based rgw daemon '{0}' available".format(rgw_host)) + self.logger.info( + "Rook based RGW daemon for node '{0}' available".format(rgw_host) + ) @staticmethod def register_execution_state(