Add better handling for the azure marketplace updates - #4221
Add better handling for the azure marketplace updates#4221sayanchowdhury wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves the Azure Marketplace publishing automation to better handle LTS channel resolution, reduce SKU version-limit churn, and add operational controls (draft deletion + dry-run) to make maintenance less manual.
Changes:
- Parse
channel-info.txtinto a key/value map, improve plan discovery, and add LTS year-to-plan resolution (lts_2024→lts2024). - Add safeguards for Azure’s 100 image-version cap by deprecating the oldest versions above a threshold, plus add “delete draft version” workflow support.
- Add
--dry-run, improve CLI help/validation, and propagate submission failures via a non-zero exit code.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
chewi
left a comment
There was a problem hiding this comment.
Seems okay, but shouldn't it deprecate more than one at a time? You might still be over the threshold after running it.
|
I'm just deprecating one version at a time, because that's how much we need and what I've been doing manually. I've just replicated what I've been doing manually |
chewi
left a comment
There was a problem hiding this comment.
I think Copilot may have raised some valid concerns, but I trust your judgement here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (3)
ci-automation/release/azure_marketplace_publish.py:120
- The LTS resolution failure message is ungrammatical and unclear, which makes it harder to diagnose broken channel-info.txt entries. It should explicitly say it couldn't find the LTS year and include matches in a readable way.
if len(matches) != 1:
logging.error(
f"Could not LTS year for version {version} in channel-info.txt, matches: {matches}"
)
ci-automation/release/azure_marketplace_publish.py:218
deprecate_oldest_image_versioncounts every version that is not "deprecated" as "live". With the new delete path setting lifecycleState to "deleted", deleted entries will still be counted as live and can cause unnecessary deprecations (and possibly pick a deleted entry as the oldest). Exclude "deleted" from the active set.
active_versions = [
v for v in image_versions if v.get("lifecycleState") != "deprecated"
]
ci-automation/release/azure_marketplace_publish.py:246
delete_draft_image_versionunconditionally marks a matching version as "deleted" without verifying it is actually a draft. If the provided version is already published/live, this will generate an invalid payload and the API will reject it (and it risks confusing output that says a draft was deleted). Add an explicit lifecycleState check before setting "deleted".
if match is None:
return None
match["lifecycleState"] = "deleted"
return match
e2fc483 to
2dae17d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (4)
ci-automation/release/azure_marketplace_publish.py:221
deprecate_oldest_image_version()treats every non-deprecatedentry as "live". That can includedraft/deleted/other states, which may cause the wrong version to be deprecated and makes the threshold check inaccurate.
active_versions = [
v for v in image_versions if v.get("lifecycleState") != "deprecated"
]
if len(active_versions) <= live_threshold:
return None
ci-automation/release/azure_marketplace_publish.py:244
delete_draft_image_version()marks any matching version asdeletedwithout checking that it's actually a draft version. If the version is already live, the API will reject the request (and the function name/help text become misleading).
match = next((v for v in image_versions if v.get("versionNumber") == version), None)
if match is None:
return None
match["lifecycleState"] = "deleted"
ci-automation/release/azure_marketplace_publish.py:121
- The error message in
resolve_lts_plan()is missing a verb ("Could not LTS year..."). This makes logs harder to parse when the mapping fails.
logging.error(
f"Could not LTS year for version {version} in channel-info.txt, matches: {matches}"
)
ci-automation/release/azure_marketplace_publish.py:495
- If
get_channel_info()fails and returns{},active_plansbecomes empty and this check logsplan value should be eitherwith no options, which hides the real failure (channel-info fetch/parse). Consider special-casing the empty list to emit a more actionable error.
if not args.test_mode and plan not in active_plans:
logging.error(f"plan value should be either {', '.join(active_plans)}")
return
|
|
||
| resp = requests.post( | ||
| url=f"https://graph.microsoft.com/rp/product-ingestion/configure", | ||
| headers={ |
This commit fixes: - Add better parsing for the LTS, earlier this was broken and the LTS release was not found in the list of supported channels. - Update the account_name to flatcar0001 - We hitting the 100 limit for the Azure images no on a regular basis so added a threshold to remove the images when the number is higher than 95 - Add the option to delete the draft versions which is quite difficult to do manually as it involves time and effort and the script works a bit differently where it handles channel across plans where if any thing needs to rectified then all the plans needs to be visited and handled manually. The commit eases the process a bit - Add a dry run mode to check if everything will be well run - Formatting using black Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
This commit fixes:
AI Usage:
dry-runfeature.