Skip to content

{AKS} Fix DCR create/update for container network logs and high log scale mode#9667

Open
carlotaarvela wants to merge 10 commits intoAzure:mainfrom
carlotaarvela:cnl-hslm-update
Open

{AKS} Fix DCR create/update for container network logs and high log scale mode#9667
carlotaarvela wants to merge 10 commits intoAzure:mainfrom
carlotaarvela:cnl-hslm-update

Conversation

@carlotaarvela
Copy link
Contributor

@carlotaarvela carlotaarvela commented Mar 10, 2026

Related command

az aks create, az aks update

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.


Description

Fixes the az aks create and az aks update commands so that the Data Collection Rule (DCR) is properly created or updated when container network logs (CNL) or high log scale mode (HLSM) flags are passed. Previously, the DCR was not being created/updated in these scenarios, causing streams like Microsoft-ContainerLogV2-HighScale to be out of sync.

Changes

Create path (AKSPreviewManagedClusterCreateDecorator):

  • Added _should_create_dcra() helper to detect when any monitoring/CNL/HLSM flag is provided, ensuring the DCRA creation postprocessing step runs.
  • When CNL or HLSM flags are passed, create_dcr=True is now set so the DCR is created/updated alongside the DCRA.

Update path (AKSPreviewManagedClusterUpdateDecorator):

  • When --enable-container-network-logs or --enable-retina-flow-logs is passed, the monitoring_addon_postprocessing_required intermediate is now set, triggering the DCR update via ensure_container_insights_for_monitoring.
  • Added validation for standalone --enable-high-log-scale-mode on the update path: requires the monitoring addon (omsagent) with MSI authentication to be enabled, otherwise raises a clear error.

Tests:

  • Added comprehensive unit tests covering the new create and update behaviors for CNL and HLSM flag combinations.

Testing

  • Unit tests: pytest src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py -k "container_network_logs or high_log_scale_mode or enable_container_network or standalone_high_log"

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

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

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

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

Hi @carlotaarvela,
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 10, 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

@yonzhan yonzhan requested a review from yanzhudd March 11, 2026 01:09
@carlotaarvela carlotaarvela changed the title Fix update enable cnl hlsm {AKS} Fix DCR create/update for container network logs and high log scale mode Mar 12, 2026
@github-actions github-actions bot added the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Mar 13, 2026
@github-actions github-actions bot removed the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Mar 13, 2026
@carlotaarvela carlotaarvela marked this pull request as ready for review March 16, 2026 19:38
Copilot AI review requested due to automatic review settings March 16, 2026 19:38
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 fixes AKS az aks create / az aks update behavior so the Azure Monitor Data Collection Rule (DCR) stays in sync when container network logs (CNL) and/or high log scale mode (HLSM) flags are used, and adds unit tests to cover those scenarios.

Changes:

  • Update create/update decorators to correctly trigger DCR/DCRA creation/update when CNL/HLSM-related flags are provided.
  • Add/extend validation and casing handling for monitoring addon profiles (omsagent vs omsAgent) in relevant paths.
  • Add comprehensive unit tests for create/update flows covering CNL/HLSM combinations and edge cases.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/aks-preview/setup.py Bumps extension version to 19.0.0b26.
src/aks-preview/azext_aks_preview/managed_cluster_decorator.py Adjusts create/update postprocessing and validation so DCR/DCRA are updated for CNL/HLSM scenarios, including addon key casing handling.
src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py Adds/extends unit tests for the new create/update behaviors and edge cases.
src/aks-preview/HISTORY.rst Documents the fix and validation changes in release notes.

You can also share your feedback on Copilot code review. Take the survey.

params = self.context.raw_param
return (
params.get("enable_addons") is not None or
params.get("enable-azure-monitor-logs") is not None or
Copy link
Member

@FumingZhang FumingZhang Mar 17, 2026

Choose a reason for hiding this comment

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

@carlotaarvela have you reviewed this comment?

"Could not create a role assignment for subnet. Are you an Owner on this subscription?"
)

def _should_create_dcra(self) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

This appears to be adding too much complex logic to the mc workflow. There is already a significant amount of code in src/aks-preview/azext_aks_preview/addonconfiguration.py and src/aks-preview/azext_aks_preview/azuremonitormetrics that manages the broader monitoring addon. We should consider refactoring this section to improve maintainability and make it easier to share between the aks enable-addons/disable-addons and aks create/update commands, with the mc profile setup and other resource mutation tasks clearly separated.

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.

Could you add some integration tests and run the existing tests to confirm that the change works as expected?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants