[aks-preview] Skip rollback auto-upgrade warning when only nodeOSUpgradeChannel is active for orchestrator-only rollback#9733
Conversation
❌Azure CLI Extensions Breaking Change Test
|
|
Hi @InduSridhar, |
|
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>
|
CodeGen Tools Feedback CollectionThank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey |
There was a problem hiding this comment.
Pull request overview
Adjusts the auto-upgrade warning shown during az aks nodepool rollback so it’s not emitted for orchestrator-only rollbacks when only nodeOSUpgradeChannel is enabled.
Changes:
- Detect orchestrator-only rollback via node image version comparison and conditionally suppress the warning for
nodeOSUpgradeChannel. - Reorder fetches so the warning logic can compare current vs rollback versions.
- Add unit tests covering warning behavior across upgrade-channel combinations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/aks-preview/azext_aks_preview/custom.py | Adds orchestrator-only rollback detection and refines auto-upgrade warning conditions. |
| src/aks-preview/azext_aks_preview/tests/latest/test_custom.py | Adds unit tests for the updated warning logic and imports the rollback function. |
| if __name__ == '__main__': | ||
| unittest.main() | ||
|
|
||
|
|
There was a problem hiding this comment.
The new test class is defined after the unittest.main() call. If this file is executed directly, unittest.main() runs before TestAgentpoolRollbackWarning is defined, so these tests won’t be discovered/executed. Move the if __name__ == '__main__': unittest.main() block to the very end of the file (after the new test class), or remove it if tests are only run via discovery.
| if __name__ == '__main__': | |
| unittest.main() |
| is_orch_version_only_rollback = ( | ||
| node_image_version and | ||
| current_agentpool.node_image_version and | ||
| node_image_version == current_agentpool.node_image_version | ||
| ) |
There was a problem hiding this comment.
The truthiness guards cause is_orch_version_only_rollback to be False when both node image versions are None/empty (even though they’re equal), which can incorrectly trigger the nodeOSUpgradeChannel warning. Compute this using direct equality instead (e.g., node_image_version == current_agentpool.node_image_version) so the ‘orch-only’ case is detected consistently, including when values are missing.
| is_orch_version_only_rollback = ( | |
| node_image_version and | |
| current_agentpool.node_image_version and | |
| node_image_version == current_agentpool.node_image_version | |
| ) | |
| # Use direct equality so that cases where both node image versions are None/empty | |
| # are correctly treated as "unchanged". | |
| is_orch_version_only_rollback = node_image_version == current_agentpool.node_image_version |
| def test_warn_when_upgrade_channel_enabled(self, _sdk, _headers): | ||
| cmd, client, mc_patch = self._build_mocks( | ||
| upgrade_channel="stable", | ||
| node_os_upgrade_channel="None", |
There was a problem hiding this comment.
Tests use the string literal \"None\" for node_os_upgrade_channel. The production code treats None and the string 'none' similarly, but using the string can mask differences in behavior and diverges from the SDK’s typical representation (None for unset). Prefer passing None here to better reflect real inputs.
| node_os_upgrade_channel="None", | |
| node_os_upgrade_channel=None, |
| def test_no_warn_when_nodeos_only_and_orch_rollback(self, _sdk, _headers): | ||
| same_image = "AKSUbuntu-2204gen2containerd-202401.01.0" |
There was a problem hiding this comment.
The new warning logic depends on how node_image_version compares when values may be missing (None/empty). Add a unit test covering the ‘orch-only’ scenario when both current and rollback node_image_version are None (and one where rollback is None but current is not) to ensure the warning is suppressed/emitted as intended.
|
Hi @InduSridhar Release SuggestionsModule: aks-preview
Notes
|
a425ecb to
823fd2f
Compare
Previously the rollback warning treated upgradeChannel and nodeOSUpgradeChannel the same, telling users rollback 'will not succeed' when either was enabled. This is misleading when only nodeOSUpgradeChannel is active — the orchestrator version rollback will succeed fine since nodeOSUpgradeChannel only manages node OS images. Split the warning into two cases: - upgradeChannel enabled: keep the existing hard warning - Only nodeOSUpgradeChannel enabled: inform users the orchestrator rollback will proceed but node image rollback will not succeed unless nodeOSUpgradeChannel is disabled
823fd2f to
eb8bad3
Compare
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
FumingZhang
left a comment
There was a problem hiding this comment.
If possible, please add some test to confirm that the change works as expected.
| upgrade_channel or "none", | ||
| node_os_upgrade_channel or "Unmanaged", | ||
| ) | ||
| elif node_os_channel_enabled: |
There was a problem hiding this comment.
Would you like to display this warning when both auto upgrade and node OS upgrade are enabled? If that's the case, you might want to use if instead of elif.
Description
When rolling back a node pool via
az aks nodepool rollback, the existing code shows the same "Rollback will not succeed" warning whenever eitherupgradeChannelornodeOSUpgradeChannelis enabled. This is misleading when onlynodeOSUpgradeChannelis active — the orchestrator version rollback will succeed fine sincenodeOSUpgradeChannelonly manages node OS images, not Kubernetes versions.Changes
Split the auto-upgrade warning in
aks_agentpool_rollback()into two cases:upgradeChannelenabled: Keep the existing hard warning — "Rollback will not succeed until auto-upgrade is disabled."nodeOSUpgradeChannelenabled: Show an accurate warning — "The orchestrator version rollback will proceed, but the node image rollback will not succeed. Please disable nodeOSUpgradeChannel if you want to roll back the node image."Testing
Manual validation — this is a warning message update only, no change to rollback execution logic.