Skip to content

[aks-preview] Skip rollback auto-upgrade warning when only nodeOSUpgradeChannel is active for orchestrator-only rollback#9733

Open
InduSridhar wants to merge 1 commit intoAzure:mainfrom
InduSridhar:fix/rollback-warning-nodeosupgrade-only
Open

[aks-preview] Skip rollback auto-upgrade warning when only nodeOSUpgradeChannel is active for orchestrator-only rollback#9733
InduSridhar wants to merge 1 commit intoAzure:mainfrom
InduSridhar:fix/rollback-warning-nodeosupgrade-only

Conversation

@InduSridhar
Copy link
Contributor

@InduSridhar InduSridhar commented Mar 26, 2026

Description

When rolling back a node pool via az aks nodepool rollback, the existing code shows the same "Rollback will not succeed" warning whenever either upgradeChannel or nodeOSUpgradeChannel is enabled. This is misleading when only nodeOSUpgradeChannel is active — the orchestrator version rollback will succeed fine since nodeOSUpgradeChannel only manages node OS images, not Kubernetes versions.

Changes

Split the auto-upgrade warning in aks_agentpool_rollback() into two cases:

  • upgradeChannel enabled: Keep the existing hard warning — "Rollback will not succeed until auto-upgrade is disabled."
  • Only nodeOSUpgradeChannel enabled: 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."
  • Neither enabled: No warning (unchanged)

Testing

Manual validation — this is a warning message update only, no change to rollback execution logic.

Copilot AI review requested due to automatic review settings March 26, 2026 22:44
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Mar 26, 2026

❌Azure CLI Extensions Breaking Change Test
❌managedcleanroom
rule cmd_name rule_message suggest_message
1006 - ParaAdd managedcleanroom collaboration add-collaborator cmd managedcleanroom collaboration add-collaborator added parameter email please remove parameter email for cmd managedcleanroom collaboration add-collaborator
1007 - ParaRemove managedcleanroom collaboration add-collaborator cmd managedcleanroom collaboration add-collaborator removed parameter object_id please add back parameter object_id for cmd managedcleanroom collaboration add-collaborator
1007 - ParaRemove managedcleanroom collaboration add-collaborator cmd managedcleanroom collaboration add-collaborator removed parameter tenant_id please add back parameter tenant_id for cmd managedcleanroom collaboration add-collaborator
1007 - ParaRemove managedcleanroom collaboration add-collaborator cmd managedcleanroom collaboration add-collaborator removed parameter user_identifier please add back parameter user_identifier for cmd managedcleanroom collaboration add-collaborator
1006 - ParaAdd managedcleanroom collaboration create cmd managedcleanroom collaboration create added parameter consortium_type please remove parameter consortium_type for cmd managedcleanroom collaboration create
1006 - ParaAdd managedcleanroom collaboration create cmd managedcleanroom collaboration create added parameter user_identity please remove parameter user_identity for cmd managedcleanroom collaboration create
1007 - ParaRemove managedcleanroom collaboration create cmd managedcleanroom collaboration create removed parameter collaborators please add back parameter collaborators for cmd managedcleanroom collaboration create
⚠️ 1006 - ParaAdd managedcleanroom collaboration update cmd managedcleanroom collaboration update added parameter consortium_type
⚠️ 1006 - ParaAdd managedcleanroom collaboration update cmd managedcleanroom collaboration update added parameter user_identity
⚠️ 1006 - ParaAdd managedcleanroom consortium create cmd managedcleanroom consortium create added parameter consortium_type
⚠️ 1006 - ParaAdd managedcleanroom consortium update cmd managedcleanroom consortium update added parameter consortium_type

@azure-client-tools-bot-prd
Copy link

Hi @InduSridhar,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 26, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Contributor

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link
Contributor

CodeGen Tools Feedback Collection

Thank 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +342 to +345
if __name__ == '__main__':
unittest.main()


Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
if __name__ == '__main__':
unittest.main()

Copilot uses AI. Check for mistakes.
Comment on lines +2314 to +2318
is_orch_version_only_rollback = (
node_image_version and
current_agentpool.node_image_version and
node_image_version == current_agentpool.node_image_version
)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
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",
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
node_os_upgrade_channel="None",
node_os_upgrade_channel=None,

Copilot uses AI. Check for mistakes.
Comment on lines +432 to +433
def test_no_warn_when_nodeos_only_and_orch_rollback(self, _sdk, _headers):
same_image = "AKSUbuntu-2204gen2containerd-202401.01.0"
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Hi @InduSridhar

Release Suggestions

Module: aks-preview

  • Please log updates into to src/aks-preview/HISTORY.rst
  • Update VERSION to 19.0.0b29 in src/aks-preview/setup.py

Notes

@InduSridhar InduSridhar force-pushed the fix/rollback-warning-nodeosupgrade-only branch 3 times, most recently from a425ecb to 823fd2f Compare March 26, 2026 23:09
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
@InduSridhar InduSridhar force-pushed the fix/rollback-warning-nodeosupgrade-only branch from 823fd2f to eb8bad3 Compare March 26, 2026 23:25
@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

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

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:
Copy link
Member

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants