Skip to content

Add better handling for the azure marketplace updates - #4221

Open
sayanchowdhury wants to merge 1 commit into
mainfrom
sayan/fix-azure-marketplace-script
Open

Add better handling for the azure marketplace updates#4221
sayanchowdhury wants to merge 1 commit into
mainfrom
sayan/fix-azure-marketplace-script

Conversation

@sayanchowdhury

Copy link
Copy Markdown
Member

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

AI Usage:

  • Used to find the endpoints of the Microsoft API-
  • Used to add comments & helpers.
  • Implement the dry-run feature.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.txt into a key/value map, improve plan discovery, and add LTS year-to-plan resolution (lts_2024lts2024).
  • 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.

Comment thread ci-automation/release/azure_marketplace_publish.py
Comment thread ci-automation/release/azure_marketplace_publish.py
Comment thread ci-automation/release/azure_marketplace_publish.py
Comment thread ci-automation/release/azure_marketplace_publish.py
Comment thread ci-automation/release/azure_marketplace_publish.py Outdated

@chewi chewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay, but shouldn't it deprecate more than one at a time? You might still be over the threshold after running it.

@sayanchowdhury

Copy link
Copy Markdown
Member Author

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 chewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Copilot may have raised some valid concerns, but I trust your judgement here.

Copilot AI review requested due to automatic review settings August 20, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_version counts 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_version unconditionally 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

Copilot AI review requested due to automatic review settings August 20, 2026 11:07
@sayanchowdhury
sayanchowdhury force-pushed the sayan/fix-azure-marketplace-script branch from e2fc483 to 2dae17d Compare August 20, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-deprecated entry as "live". That can include draft/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 as deleted without 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_plans becomes empty and this check logs plan value should be either with 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Testing / in Review

Development

Successfully merging this pull request may close these issues.

3 participants