diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index e20aa860346..a80895e4413 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -12,6 +12,7 @@ To release a new version, please select a new version number (usually plus 1 to Pending +++++++ * `az aks alert-config add`: Reject an empty `--name` before looking up existing configurations instead of reporting that it already exists. +* `az aks enable-addons`, `az aks disable-addons` and `az aks update`: Keep Container Insights monitoring and container network log settings consistent with the legacy monitoring addon when updating clusters. 22.0.0b7 +++++++++ diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index f925723cec4..78986c60b06 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -4085,6 +4085,19 @@ def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements raise CLIError(f"The addon {addon} is not installed.") addon_profiles[addon].config = None addon_profiles[addon].enabled = enable + if addon == CONST_MONITORING_ADDON_NAME: + monitor_profile = getattr(instance, "azure_monitor_profile", None) + if getattr(monitor_profile, "container_insights", None) is not None: + # Reset canonical monitoring values along with the legacy addon config. + ContainerInsights = cmd.get_models( + "ManagedClusterAzureMonitorProfileContainerInsights", + resource_type=CUSTOM_MGMT_AKS_PREVIEW, + operation_group="managed_clusters", + ) + monitor_profile.container_insights = ContainerInsights( + enabled=enable, + log_analytics_workspace_resource_id=workspace_resource_id if enable else None, + ) instance.addon_profiles = addon_profiles diff --git a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py index a9a88b3c8e8..7fef93edcb7 100644 --- a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py @@ -6662,6 +6662,11 @@ def update_monitoring_profile_flow_logs(self, mc: ManagedCluster) -> ManagedClus config = monitoring_addon_profile.config or {} config["enableRetinaNetworkFlags"] = str(container_network_logs_enabled) mc.addon_profiles[monitoring_addon_key].config = config + container_insights = getattr(mc.azure_monitor_profile, "container_insights", None) + if container_insights is not None: + container_insights.container_network_logs = ( + "Enabled" if container_network_logs_enabled else "Disabled" + ) # When enabling CNL, the DCR must be updated to add the high-scale stream. # Set the postprocessing intermediate so that the update path calls ensure_container_insights. diff --git a/src/aks-preview/azext_aks_preview/tests/latest/data/setup_proxy.sh b/src/aks-preview/azext_aks_preview/tests/latest/data/setup_proxy.sh index 879a0988688..9d0765970ae 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/data/setup_proxy.sh +++ b/src/aks-preview/azext_aks_preview/tests/latest/data/setup_proxy.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -x +set -euxo pipefail echo "setting up" WORKDIR="${1:-$(mktemp -d)}" @@ -7,22 +7,14 @@ echo "setting up ${WORKDIR}" pushd "$WORKDIR" -apt update -y && apt install -y apt-transport-https curl gnupg make gcc < /dev/null - -# add diladele apt key -wget -qO - https://packages.diladele.com/diladele_pub.asc | apt-key add - - -# add new repo -tee /etc/apt/sources.list.d/squid413-ubuntu20.diladele.com.list <