Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 1dfe578

Browse files
Fix KeyError issues introduced in #86
Signed-off-by: Tobias Wolf <[email protected]>
1 parent 2cc2047 commit 1dfe578

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

src/rookify/modules/ceph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _json_command(self, handler: Any, *args: Any) -> Any:
3232

3333
return data
3434

35-
def get_osd_pool_configurations_from_osd_dump(
35+
def get_osd_pool_configurations_from_map(
3636
self, dump_data: Dict[str, Any]
3737
) -> Dict[str, Any]:
3838
osd_pools = {osd_pool["pool_name"]: osd_pool for osd_pool in dump_data["pools"]}

src/rookify/modules/create_rook_resources/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __create_configmap_definition(self) -> None:
3636
configmap_data = {
3737
"data": configmap_mon_list,
3838
"mapping": json.dumps({"node": mapping}),
39-
"maxMonId": "{0:d}".format(len(state_data["mon"]["dump"]["mons"])),
39+
"maxMonId": "{0:d}".format(len(state_data["report"]["monmap"]["mons"])),
4040
}
4141

4242
configmap = kubernetes.client.V1ConfigMap(

src/rookify/modules/migrate_mds_pools/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def preflight(self) -> None:
1616
"MigrateMdsPoolsHandler", "pools", default_value={}
1717
)
1818

19-
osd_pools = self.ceph.get_osd_pool_configurations_from_osd_dump(
20-
state_data["osd"]["dump"]
19+
osd_pools = self.ceph.get_osd_pool_configurations_from_map(
20+
state_data["report"]["osdmap"]
2121
)
2222

2323
for mds_fs_data in state_data["fs"]["ls"]:

src/rookify/modules/migrate_osd_pools/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _get_filtered_osd_pools_list(self) -> List[Dict[str, Any]]:
3232

3333
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data
3434

35-
osd_pool_configurations = self.ceph.get_osd_pool_configurations_from_osd_dump(
35+
osd_pool_configurations = self.ceph.get_osd_pool_configurations_from_map(
3636
state_data["report"]["osdmap"]
3737
)
3838

src/rookify/modules/migrate_osds/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def _get_devices_of_hosts(self) -> Dict[str, Dict[str, str]]:
1616

1717
osd_devices: Dict[str, Dict[str, str]] = {}
1818
osd_metadata = {
19-
str(osd_data["id"]): osd_data for osd_data in state_data["osd_metadata"]
19+
osd_data["id"]: osd_data
20+
for osd_data in state_data["report"]["osd_metadata"]
2021
}
2122

2223
for osd_host, osds in state_data["node"]["ls"]["osd"].items():

src/rookify/modules/migrate_rgw_pools/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def preflight(self) -> None:
3737
else:
3838
zones[zone_name] = {"osd_pools": {}, "rgw_count": 1}
3939

40-
osd_pools = self.ceph.get_osd_pool_configurations_from_osd_dump(
40+
osd_pools = self.ceph.get_osd_pool_configurations_from_map(
4141
state_data["report"]["osdmap"]
4242
)
4343

src/rookify/modules/migrate_rgws/main.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ class MigrateRgwsHandler(ModuleHandler):
1313
def _get_rgw_daemon_hosts(self) -> List[str]:
1414
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data
1515

16-
rgw_daemons = state_data["report"]["servicemap"]["services"]["rgw"]["daemons"]
16+
return self._get_rgw_daemon_hosts_of_map(
17+
state_data["report"]["servicemap"]["services"]["rgw"]["daemons"]
18+
)
19+
20+
def _get_rgw_daemon_hosts_of_map(
21+
self, rgw_daemons_map: Dict[str, Any]
22+
) -> List[str]:
1723
rgw_daemon_hosts = []
1824

19-
if "summary" in rgw_daemons:
20-
del rgw_daemons["summary"]
25+
if "summary" in rgw_daemons_map:
26+
del rgw_daemons_map["summary"]
2127

22-
for rgw_daemon in rgw_daemons.values():
28+
for rgw_daemon in rgw_daemons_map.values():
2329
if "metadata" not in rgw_daemon or "hostname" not in rgw_daemon["metadata"]:
2430
raise ModuleException(
2531
"Unexpected ceph-rgw daemon metadata: {0}".format(rgw_daemon)
@@ -89,7 +95,11 @@ def _migrate_rgw(self, rgw_host: str) -> None:
8995
)
9096

9197
while True:
92-
rgw_daemon_hosts = self._get_rgw_daemon_hosts()
98+
ceph_status = self.ceph.mon_command("status")
99+
100+
rgw_daemon_hosts = self._get_rgw_daemon_hosts_of_map(
101+
ceph_status["servicemap"]["services"]["rgw"]["daemons"]
102+
)
93103

94104
if rgw_host not in rgw_daemon_hosts:
95105
break

0 commit comments

Comments
 (0)