Skip to content

Commit 1ee92ae

Browse files
authored
fix: Fix output handling (#2059)
1 parent b09779b commit 1ee92ae

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

release-controller/dre_cli.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,8 @@ def get_blessed_guestos_versions(self) -> set[str]:
150150
# `dre get` forwards its arguments verbatim to `ic-admin`, so the
151151
# output format is dictated by the ic-admin build that matches the
152152
# currently deployed registry canister (downloaded at runtime), not
153-
# by this code. Newer ic-admin releases ignore `--json` for this
154-
# subcommand and print a plain newline-separated list of version IDs;
155-
# older ones wrapped it in {"value": {"blessed_version_ids": [...]}}.
156-
# Accept both so a registry-canister upgrade can't break us again.
153+
# by this code. With the migration away from blessed versions, ic-admin
154+
# has had a few formats. Support all of them here.
157155
output = subprocess.check_output(
158156
[self.cli, "get", "blessed-replica-versions", "--json"],
159157
env=self.env,
@@ -163,11 +161,18 @@ def get_blessed_guestos_versions(self) -> set[str]:
163161
parsed = json.loads(output)
164162
except json.JSONDecodeError:
165163
parsed = None
164+
165+
# Old format
166166
if isinstance(parsed, dict):
167167
return set(
168168
typing.cast(list[str], parsed["value"]["blessed_version_ids"])
169169
)
170-
return {line.strip() for line in output.splitlines() if line.strip()}
170+
# New format, with --json support
171+
elif isinstance(parsed, list):
172+
return set(parsed)
173+
# New format, without --json support
174+
else:
175+
return {line.strip() for line in output.splitlines() if line.strip()}
171176

172177
def get_blessed_hostos_versions(self) -> set[str]:
173178
"""Query the blessed HostOS versions."""

0 commit comments

Comments
 (0)