{AKS} Fix DCR create/update for container network logs and high log scale mode#9667
{AKS} Fix DCR create/update for container network logs and high log scale mode#9667carlotaarvela wants to merge 10 commits intoAzure:mainfrom
Conversation
️✔️Azure CLI Extensions Breaking Change Test
|
|
Hi @carlotaarvela, |
|
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 |
|
955792f to
43c3a1f
Compare
There was a problem hiding this comment.
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 (
omsagentvsomsAgent) 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 |
| "Could not create a role assignment for subnet. Are you an Owner on this subscription?" | ||
| ) | ||
|
|
||
| def _should_create_dcra(self) -> bool: |
There was a problem hiding this comment.
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.
FumingZhang
left a comment
There was a problem hiding this comment.
Could you add some integration tests and run the existing tests to confirm that the change works as expected?
Related command
az aks create,az aks updateGeneral 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.Description
Fixes the
az aks createandaz aks updatecommands 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 likeMicrosoft-ContainerLogV2-HighScaleto be out of sync.Changes
Create path (
AKSPreviewManagedClusterCreateDecorator):_should_create_dcra()helper to detect when any monitoring/CNL/HLSM flag is provided, ensuring the DCRA creation postprocessing step runs.create_dcr=Trueis now set so the DCR is created/updated alongside the DCRA.Update path (
AKSPreviewManagedClusterUpdateDecorator):--enable-container-network-logsor--enable-retina-flow-logsis passed, themonitoring_addon_postprocessing_requiredintermediate is now set, triggering the DCR update viaensure_container_insights_for_monitoring.--enable-high-log-scale-modeon the update path: requires the monitoring addon (omsagent) with MSI authentication to be enabled, otherwise raises a clear error.Tests:
Testing
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"