Skip to content

Commit

Permalink
Fix KeyError issues introduced in #86
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne authored Oct 23, 2024
1 parent 2cc2047 commit 1dfe578
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/rookify/modules/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _json_command(self, handler: Any, *args: Any) -> Any:

return data

def get_osd_pool_configurations_from_osd_dump(
def get_osd_pool_configurations_from_map(
self, dump_data: Dict[str, Any]
) -> Dict[str, Any]:
osd_pools = {osd_pool["pool_name"]: osd_pool for osd_pool in dump_data["pools"]}
Expand Down
2 changes: 1 addition & 1 deletion src/rookify/modules/create_rook_resources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __create_configmap_definition(self) -> None:
configmap_data = {
"data": configmap_mon_list,
"mapping": json.dumps({"node": mapping}),
"maxMonId": "{0:d}".format(len(state_data["mon"]["dump"]["mons"])),
"maxMonId": "{0:d}".format(len(state_data["report"]["monmap"]["mons"])),
}

configmap = kubernetes.client.V1ConfigMap(
Expand Down
4 changes: 2 additions & 2 deletions src/rookify/modules/migrate_mds_pools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def preflight(self) -> None:
"MigrateMdsPoolsHandler", "pools", default_value={}
)

osd_pools = self.ceph.get_osd_pool_configurations_from_osd_dump(
state_data["osd"]["dump"]
osd_pools = self.ceph.get_osd_pool_configurations_from_map(
state_data["report"]["osdmap"]
)

for mds_fs_data in state_data["fs"]["ls"]:
Expand Down
2 changes: 1 addition & 1 deletion src/rookify/modules/migrate_osd_pools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _get_filtered_osd_pools_list(self) -> List[Dict[str, Any]]:

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

osd_pool_configurations = self.ceph.get_osd_pool_configurations_from_osd_dump(
osd_pool_configurations = self.ceph.get_osd_pool_configurations_from_map(
state_data["report"]["osdmap"]
)

Expand Down
3 changes: 2 additions & 1 deletion src/rookify/modules/migrate_osds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def _get_devices_of_hosts(self) -> Dict[str, Dict[str, str]]:

osd_devices: Dict[str, Dict[str, str]] = {}
osd_metadata = {
str(osd_data["id"]): osd_data for osd_data in state_data["osd_metadata"]
osd_data["id"]: osd_data
for osd_data in state_data["report"]["osd_metadata"]
}

for osd_host, osds in state_data["node"]["ls"]["osd"].items():
Expand Down
2 changes: 1 addition & 1 deletion src/rookify/modules/migrate_rgw_pools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def preflight(self) -> None:
else:
zones[zone_name] = {"osd_pools": {}, "rgw_count": 1}

osd_pools = self.ceph.get_osd_pool_configurations_from_osd_dump(
osd_pools = self.ceph.get_osd_pool_configurations_from_map(
state_data["report"]["osdmap"]
)

Expand Down
20 changes: 15 additions & 5 deletions src/rookify/modules/migrate_rgws/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ class MigrateRgwsHandler(ModuleHandler):
def _get_rgw_daemon_hosts(self) -> List[str]:
state_data = self.machine.get_preflight_state("AnalyzeCephHandler").data

rgw_daemons = state_data["report"]["servicemap"]["services"]["rgw"]["daemons"]
return self._get_rgw_daemon_hosts_of_map(
state_data["report"]["servicemap"]["services"]["rgw"]["daemons"]
)

def _get_rgw_daemon_hosts_of_map(
self, rgw_daemons_map: Dict[str, Any]
) -> List[str]:
rgw_daemon_hosts = []

if "summary" in rgw_daemons:
del rgw_daemons["summary"]
if "summary" in rgw_daemons_map:
del rgw_daemons_map["summary"]

for rgw_daemon in rgw_daemons.values():
for rgw_daemon in rgw_daemons_map.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)
Expand Down Expand Up @@ -89,7 +95,11 @@ def _migrate_rgw(self, rgw_host: str) -> None:
)

while True:
rgw_daemon_hosts = self._get_rgw_daemon_hosts()
ceph_status = self.ceph.mon_command("status")

rgw_daemon_hosts = self._get_rgw_daemon_hosts_of_map(
ceph_status["servicemap"]["services"]["rgw"]["daemons"]
)

if rgw_host not in rgw_daemon_hosts:
break
Expand Down

0 comments on commit 1dfe578

Please sign in to comment.