{AKS}: bump aks-agent and upgrade helm charts automatically#9606
{AKS}: bump aks-agent and upgrade helm charts automatically#9606
Conversation
️✔️Azure CLI Extensions Breaking Change Test
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
There was a problem hiding this comment.
Pull request overview
This PR updates the aks-agent Azure CLI extension to a new beta release and adds an automatic Helm chart upgrade path when running az aks agent in cluster mode, aligning the deployed agent/chart with the extension’s expected version.
Changes:
- Bump extension version to
1.0.0b18and document the release notes. - Update expected AKS agent Helm chart version to
0.3.0and client-mode Docker image tov0.3.0-client. - Add deployed chart version detection and auto-upgrade logic during
az aks agent.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/aks-agent/setup.py |
Bumps extension package version to 1.0.0b18. |
src/aks-agent/azext_aks_agent/custom.py |
Runs an auto-upgrade flow during az aks agent when a chart version mismatch is detected. |
src/aks-agent/azext_aks_agent/agent/k8s/aks_agent_manager.py |
Updates expected chart/image versions and adds chart-version extraction plus check_upgrade_needed(). |
src/aks-agent/HISTORY.rst |
Adds 1.0.0b18 changelog entry and fixes a prior formatting issue. |
| def check_upgrade_needed(self) -> Tuple[bool, Optional[str], Optional[str]]: | ||
| """ | ||
| Check if the deployed helm chart version differs from the expected version. | ||
|
|
||
| Returns: | ||
| Tuple[bool, Optional[str], Optional[str]]: | ||
| - needs_upgrade: True if upgrade is needed, False otherwise | ||
| - deployed_version: The currently deployed version (or None if unknown) | ||
| - expected_version: The expected version to upgrade to (or None if no upgrade needed) | ||
| """ | ||
| agent_status = self.get_agent_status() | ||
| helm_status = agent_status.get("helm_status", "not_found") | ||
|
|
||
| if helm_status not in ["deployed", "superseded"]: | ||
| logger.debug("Agent not deployed or in unexpected state: %s", helm_status) | ||
| return False, None, None | ||
|
|
||
| deployed_version = agent_status.get("chart_version") | ||
| expected_version = self.chart_version | ||
|
|
||
| if not deployed_version: | ||
| logger.warning("Could not determine deployed chart version") | ||
| return False, None, None | ||
|
|
||
| if deployed_version == expected_version: | ||
| logger.debug("Chart version is up to date: %s", deployed_version) | ||
| return False, deployed_version, None | ||
|
|
||
| logger.info( | ||
| "Chart version mismatch detected. Deployed: %s, Expected: %s", | ||
| deployed_version, expected_version | ||
| ) | ||
|
|
||
| return True, deployed_version, expected_version |
There was a problem hiding this comment.
New check_upgrade_needed() behavior is untested. There are existing unit tests for AKSAgentManager (e.g., test_get_agent_status) but nothing covering version extraction / mismatch detection. Add tests to validate: (1) matching version returns (False, deployed_version, None), (2) mismatch returns (True, deployed_version, expected_version), and (3) missing/unknown deployed version returns (False, None, None).
| "Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.", | ||
| style=INFO_COLOR) | ||
| except AzCLIError as e: | ||
| console.print( | ||
| f"⚠️ Warning: Failed to auto-upgrade agent: {e}", | ||
| style=WARNING_COLOR) | ||
| console.print( | ||
| "Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.", |
There was a problem hiding this comment.
The warning suggests running az aks agent-upgrade, but this extension’s command table only defines az aks agent, az aks agent-init, and az aks agent-cleanup (no agent-upgrade). This will mislead users if auto-upgrade fails. Update the message to reference an existing command (or add the missing command if intended).
| "Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.", | |
| style=INFO_COLOR) | |
| except AzCLIError as e: | |
| console.print( | |
| f"⚠️ Warning: Failed to auto-upgrade agent: {e}", | |
| style=WARNING_COLOR) | |
| console.print( | |
| "Continuing with the current version. Run 'az aks agent-upgrade' to manually upgrade.", | |
| "Continuing with the current version. Run 'az aks agent-init' to manually upgrade.", | |
| style=INFO_COLOR) | |
| except AzCLIError as e: | |
| console.print( | |
| f"⚠️ Warning: Failed to auto-upgrade agent: {e}", | |
| style=WARNING_COLOR) | |
| console.print( | |
| "Continuing with the current version. Run 'az aks agent-init' to manually upgrade.", |
| ++++++++ | ||
| * Bump aks-agent to v0.3.0 | ||
| * chore: use aks mcp streamable-http mode | ||
| * Remove runbook toolset until it's stablized |
There was a problem hiding this comment.
Typo in changelog entry: "stablized" should be "stabilized".
| * Remove runbook toolset until it's stablized | |
| * Remove runbook toolset until it's stabilized |
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.