Skip to content

fix(aks-preview): preserve existing ACNS settings during partial updates#9720

Open
nddq wants to merge 1 commit intoAzure:mainfrom
nddq:fix/acns-update-preserve-existing-state
Open

fix(aks-preview): preserve existing ACNS settings during partial updates#9720
nddq wants to merge 1 commit intoAzure:mainfrom
nddq:fix/acns-update-preserve-existing-state

Conversation

@nddq
Copy link
Member

@nddq nddq commented Mar 25, 2026

Currently update_acns_in_network_profile creates a new AdvancedNetworking object on every update call, replacing the existing one wholesale. When a user updates only a single ACNS sub-property (e.g. --acns-advanced-networkpolicies L7), existing sub-properties like observability, security, transit encryption, and performance are discarded because they weren't re-specified.

This PR changes the update path to modify the existing AdvancedNetworking object in-place, only overwriting fields the user explicitly provided.

  • Decorator: Mutate mc.network_profile.advanced_networking in-place instead of constructing a fresh object and replacing it
  • Unit tests: Add test_update_acns_in_network_profile_preserves_existing_state covering partial updates to network policies, observability, and disable flows
  • Live test: Add test_aks_update_acns_preserves_existing_settings — creates a cluster with ACNS, updates only network policies, then updates only transit encryption, verifying all existing settings survive each step

Testing

Unit tests:

python -m pytest src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py -k "test_update_acns_in_network_profile" -xvs
# 2 passed

Live test:

python -m pytest src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py -k "test_aks_update_acns_preserves_existing_settings" -xvs
# 1 passed in 769.53s

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

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

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 25, 2026

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

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

Hi @nddq,
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.

@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

@github-actions
Copy link
Contributor

Hi @nddq

Release Suggestions

Module: aks-preview

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

Notes

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

This PR updates the aks-preview managed cluster update path so partial ACNS updates (e.g., changing only advanced network policies or transit encryption) don’t unintentionally wipe other existing advancedNetworking sub-settings.

Changes:

  • Update update_acns_in_network_profile to mutate mc.network_profile.advanced_networking in-place instead of replacing it wholesale.
  • Add a unit test covering preservation of existing ACNS state across partial updates.
  • Add a live test that creates a cluster with ACNS and verifies settings persist across sequential partial updates.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/aks-preview/azext_aks_preview/managed_cluster_decorator.py Switch ACNS update logic to preserve existing advanced_networking sub-objects and only overwrite user-specified fields.
src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py Add unit coverage for preserving existing ACNS settings during partial updates (and disable path expectations).
src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py Add a live test validating partial aks update operations don’t drop previously configured ACNS settings.

The update_acns_in_network_profile method was creating a new
AdvancedNetworking object on every update, discarding existing
sub-properties (observability, security, transit encryption, performance)
that the user didn't explicitly specify. This changes the method to
modify the existing object in-place, only overwriting fields the user
provided.

Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
@nddq nddq force-pushed the fix/acns-update-preserve-existing-state branch from 2991958 to 08a5334 Compare March 25, 2026 22:58
@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.

Please leave a note about your change in HISTORY.rst

name_prefix="clitest",
location="westcentralus",
)
def test_aks_update_acns_preserves_existing_settings(
Copy link
Member

Choose a reason for hiding this comment

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

Queued live test to validate the change.

You might consider running the test with other related existing test cases to make sure the change doesn't cause any regression.

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