Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@
type: string
short-summary: Set transit encryption type for ACNS security.
long-summary: Configures pod-to-pod encryption for Cilium-based clusters. Once enabled, all traffic between Cilium managed pods will be encrypted when it leaves the node boundary. Valid values are "WireGuard" and "None". When creating a cluster, this option must be used together with "--enable-acns"; when updating a cluster, it can be used on its own to modify the transit encryption type for an existing ACNS-enabled cluster.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --nrg-lockdown-restriction-level
type: string
short-summary: Restriction level on the managed node resource group.
Expand Down
24 changes: 24 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@
ManagedCluster = TypeVar("ManagedCluster")


def get_monitoring_addon_key(addon_profiles, monitoring_addon_name):
"""Return the canonical key for the monitoring addon, normalizing non-standard casing.

The API response may return the monitoring addon key in any casing (e.g.
"omsagent", "omsAgent", "oMSaGent"). This helper performs a
case-insensitive lookup and, when a non-standard key is found, re-keys
addon_profiles in-place so that subsequent code always uses the canonical
``monitoring_addon_name`` (lowercase) form.
"""
if addon_profiles is None:
return monitoring_addon_name
# Exact match on the canonical lowercase name – preferred form.
if monitoring_addon_name in addon_profiles:
return monitoring_addon_name
# Case-insensitive fallback: catch any casing the server may return.
target_lower = monitoring_addon_name.lower()
for key in list(addon_profiles):
if key.lower() == target_lower:
# Normalize: move the profile to the canonical key.
addon_profiles[monitoring_addon_name] = addon_profiles.pop(key)
return monitoring_addon_name
return monitoring_addon_name


def format_parameter_name_to_option_name(parameter_name: str) -> str:
"""Convert a name in parameter format to option format.

Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ def load_arguments(self, _):
help="Set the datapath acceleration mode for Azure Container Networking Solution (ACNS). Valid values are 'BpfVeth' and 'None'."
)
c.argument('acns_transit_encryption_type', arg_type=get_enum_type(transit_encryption_types))
# monitoring addons
c.argument('enable_high_log_scale_mode', arg_type=get_three_state_flag())
# private cluster parameters
c.argument('enable_apiserver_vnet_integration', action='store_true')
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id)
Expand Down
40 changes: 28 additions & 12 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
CONST_VIRTUAL_MACHINES,
)
from azure.cli.command_modules.acs._polling import RunCommandLocationPolling
from azure.cli.command_modules.acs._helpers import get_snapshot_by_snapshot_id, check_is_private_link_cluster, build_etag_kwargs
from azure.cli.command_modules.acs._helpers import get_snapshot_by_snapshot_id, get_monitoring_addon_key, check_is_private_link_cluster, build_etag_kwargs
from azure.cli.command_modules.acs._resourcegroup import get_rg_location
from azure.cli.command_modules.acs.managednamespace import aks_managed_namespace_add, aks_managed_namespace_update
from azure.cli.command_modules.acs._validators import extract_comma_separated_string
Expand Down Expand Up @@ -1168,6 +1168,8 @@ def aks_update(
disable_container_network_logs=None,
acns_datapath_acceleration_mode=None,
acns_transit_encryption_type=None,
# monitoring addons
enable_high_log_scale_mode=None,
# network isoalted cluster
bootstrap_artifact_source=None,
bootstrap_container_registry_resource_id=None,
Expand Down Expand Up @@ -1516,15 +1518,18 @@ def _remove_nulls(managed_clusters):
def aks_disable_addons(cmd, client, resource_group_name, name, addons, no_wait=False):
instance = client.get(resource_group_name, name)
subscription_id = get_subscription_id(cmd.cli_ctx)
monitoring_addon_key = get_monitoring_addon_key(
instance.addon_profiles, CONST_MONITORING_ADDON_NAME
)
try:
if addons == "monitoring" and CONST_MONITORING_ADDON_NAME in instance.addon_profiles and \
instance.addon_profiles[CONST_MONITORING_ADDON_NAME].enabled and \
CONST_MONITORING_USING_AAD_MSI_AUTH in instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config and \
str(instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config[CONST_MONITORING_USING_AAD_MSI_AUTH]).lower() == 'true':
if addons == "monitoring" and monitoring_addon_key in instance.addon_profiles and \
instance.addon_profiles[monitoring_addon_key].enabled and \
CONST_MONITORING_USING_AAD_MSI_AUTH in instance.addon_profiles[monitoring_addon_key].config and \
str(instance.addon_profiles[monitoring_addon_key].config[CONST_MONITORING_USING_AAD_MSI_AUTH]).lower() == 'true':
# remove the DCR association because otherwise the DCR can't be deleted
ensure_container_insights_for_monitoring(
cmd,
instance.addon_profiles[CONST_MONITORING_ADDON_NAME],
instance.addon_profiles[monitoring_addon_key],
subscription_id,
resource_group_name,
name,
Expand Down Expand Up @@ -1614,12 +1619,20 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons,

if need_pull_for_result:
if enable_monitoring:
if CONST_MONITORING_USING_AAD_MSI_AUTH in instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config and \
str(instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config[CONST_MONITORING_USING_AAD_MSI_AUTH]).lower() == 'true':
monitoring_addon_key = get_monitoring_addon_key(
instance.addon_profiles, CONST_MONITORING_ADDON_NAME
)
if CONST_MONITORING_USING_AAD_MSI_AUTH in instance.addon_profiles[monitoring_addon_key].config and \
str(instance.addon_profiles[monitoring_addon_key].config[CONST_MONITORING_USING_AAD_MSI_AUTH]).lower() == 'true':
if msi_auth:
# Auto-enable HLSM when CNL is active and HLSM not explicitly set
if enable_high_log_scale_mode is None and \
(instance.addon_profiles[monitoring_addon_key].config or {}).get(
"enableRetinaNetworkFlags", "").lower() == "true":
enable_high_log_scale_mode = True
# create a Data Collection Rule (DCR) and associate it with the cluster
ensure_container_insights_for_monitoring(
cmd, instance.addon_profiles[CONST_MONITORING_ADDON_NAME],
cmd, instance.addon_profiles[monitoring_addon_key],
subscription_id,
resource_group_name,
name,
Expand Down Expand Up @@ -1650,7 +1663,7 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons,
raise ArgumentUsageError(
"--ampls-resource-id supported only in MSI auth mode.")
ensure_container_insights_for_monitoring(
cmd, instance.addon_profiles[CONST_MONITORING_ADDON_NAME], subscription_id, resource_group_name, name, instance.location, aad_route=False)
cmd, instance.addon_profiles[monitoring_addon_key], subscription_id, resource_group_name, name, instance.location, aad_route=False)

# adding a wait here since we rely on the result for role assignment
result = LongRunningOperation(cmd.cli_ctx)(
Expand Down Expand Up @@ -4078,8 +4091,11 @@ def is_monitoring_addon_enabled(addons, instance):
break

addon_profiles = instance.addon_profiles or {}
monitoring_addon_enabled = is_monitoring_addon and CONST_MONITORING_ADDON_NAME in addon_profiles and addon_profiles[
CONST_MONITORING_ADDON_NAME].enabled
monitoring_addon_key = get_monitoring_addon_key(
addon_profiles, CONST_MONITORING_ADDON_NAME
)
monitoring_addon_enabled = is_monitoring_addon and monitoring_addon_key in addon_profiles and addon_profiles[
monitoring_addon_key].enabled
except Exception as ex: # pylint: disable=broad-except
logger.debug("failed to check monitoring addon enabled: %s", ex)
return monitoring_addon_enabled
Loading
Loading