← Back to Pull requests

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

Closed
unknown closed this pull request without merging on Apr 24, 2026 04:23 UTC
View on GitHub
unknown unknown commented on Mar 10, 2026 15:48 UTC
Author

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:

  • My extension description/summary conforms to the Extension Summary Guidelines.
  • 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.

    Also fixes --disable-azure-monitor-logs so it actually disables monitoring by setting azureMonitorProfile.containerInsights.enabled = False (the RP's source of truth), and handles omsAgent vs omsagent key casing inconsistencies from the Azure API.

    Changes

    Shared utilities:

  • Added _get_monitoring_addon_key() helper to resolve the monitoring addon key from a cluster's addon_profiles, handling both omsagent and omsAgent key variants returned by the API.
  • Context (AKSPreviewManagedClusterContext):

  • Fixed get_enable_msi_auth_for_monitoring() to detect MSI auth on clusters where service_principal_profile.client_id is "msi" by checking the addon's useAADAuth config instead of returning False.

  • Fixed get_container_network_logs() and get_enable_high_log_scale_mode() to handle both omsagent and omsAgent addon key variants.

  • Added validation: disabling HLSM while CNL is still enabled now raises a MutuallyExclusiveArgumentError.

  • Added enable_high_log_scale_mode to the special parameter defaults list so standalone --enable-high-log-scale-mode passes the check_raw_parameters gate.
  • Create path (AKSPreviewManagedClusterCreateDecorator):

  • Moved DCR creation from postprocessing to _setup_azure_monitor_logs() (pre-PUT), matching the base class build_monitoring_addon_profile pattern. DCRA is still created in postprocessing.

  • Added _should_create_dcra() and _is_cnl_or_hlsm_changing() helpers to detect when CNL/HLSM flags require DCR/DCRA creation.

  • Refactored _postprocess_monitoring_enable() and _postprocess_monitoring_disable() into reusable methods.
  • Update path (AKSPreviewManagedClusterUpdateDecorator):

  • update_monitoring_profile_flow_logs(): Added base class delegation (super().update_monitoring_profile_flow_logs(mc)) for CLI >= 2.84.0 compatibility, and guarded the call site in update_mc_profile_preview() to avoid double execution.

  • 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: requires the monitoring addon with MSI auth to be enabled, with an escape hatch when --enable-azure-monitor-logs is passed simultaneously.

  • Added validation for --enable-high-log-scale-mode false: prevents disabling HLSM while CNL is still enabled.

  • Fixed _disable_azure_monitor_logs(): now sets mc.azure_monitor_profile.container_insights.enabled = False (the RP source of truth) and uses config = None instead of config = {} to match the base CLI behavior.

  • Fixed monitoring postprocessing to use _get_monitoring_addon_key() for correct key resolution.
  • Tests:

  • 6 new live integration tests: test_aks_create_with_azuremonitorlogs_and_cnl, test_aks_update_enable_azuremonitorlogs_with_hlsm, test_aks_create_with_retina_flow_logs_alias, test_aks_update_enable_cnl_via_azuremonitorlogs, test_aks_update_disable_azuremonitorlogs, test_aks_update_standalone_enable_high_log_scale_mode.

  • 38 new unit tests covering context methods, create decorator, update decorator, postprocessing, key casing, and validation error paths.
  • 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 or disable_azure_monitor or postprocessing_create_dcr or update_monitoring_profile_flow_logs"

  • Live integration tests: AZURE_TEST_RUN_LIVE=true pytest src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py -k "test_aks_create_with_azuremonitorlogs_and_cnl or test_aks_update_enable_azuremonitorlogs_with_hlsm or test_aks_create_with_retina_flow_logs_alias or test_aks_update_enable_cnl_via_azuremonitorlogs or test_aks_update_disable_azuremonitorlogs or test_aks_update_standalone_enable_high_log_scale_mode"
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: carlotaarvela Review duration: 64114m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9667"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%