Merge pull request 'Fix iSCSI target cascade failures on portal create error' (#3) from devel into main
This commit is contained in:
@@ -386,21 +386,24 @@ async def _migrate_iscsi_targets(
|
||||
summary.iscsi_targets_skipped += 1
|
||||
continue
|
||||
|
||||
# Verify all referenced portals and initiators were successfully mapped
|
||||
missing = []
|
||||
# Filter out groups whose portal or initiator could not be mapped (e.g. portal
|
||||
# creation failed). Warn per dropped group but still create the target — a
|
||||
# target without every portal group is valid and preferable to no target at all.
|
||||
valid_groups = []
|
||||
for g in target.get("groups", []):
|
||||
unmapped = []
|
||||
if g.get("portal") not in portal_id_map:
|
||||
missing.append(f"portal id={g['portal']}")
|
||||
unmapped.append(f"portal id={g['portal']}")
|
||||
if g.get("initiator") not in initiator_id_map:
|
||||
missing.append(f"initiator id={g['initiator']}")
|
||||
if missing:
|
||||
msg = f"iSCSI target {name!r}: cannot remap {', '.join(missing)}"
|
||||
log.error(" %s: %s", _bold_red("SKIP"), msg)
|
||||
summary.iscsi_targets_failed += 1
|
||||
summary.errors.append(msg)
|
||||
continue
|
||||
unmapped.append(f"initiator id={g['initiator']}")
|
||||
if unmapped:
|
||||
log.warning(" %s dropping group with unmapped %s",
|
||||
_yellow("WARN"), ", ".join(unmapped))
|
||||
else:
|
||||
valid_groups.append(g)
|
||||
|
||||
payload = _iscsi_target_payload(target, portal_id_map, initiator_id_map)
|
||||
payload = _iscsi_target_payload({**target, "groups": valid_groups},
|
||||
portal_id_map, initiator_id_map)
|
||||
log.debug(" payload: %s", json.dumps(payload))
|
||||
|
||||
if dry_run:
|
||||
|
||||
Reference in New Issue
Block a user