Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

19.0.0b21
+++++++
* `az aks create/update`: Automatically enable `--enable-high-log-scale-mode` when `--enable-container-network-logs` is specified. Raises an error if user explicitly disables HLSM while enabling CNL.

19.0.0b20
+++++++
* `az aks bastion`: Add new option `--kubeconfig-path` to allow users to specify an existing kubeconfig file
Expand Down
14 changes: 7 additions & 7 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
short-summary: Enable advanced network flow log collection functionalities on a cluster. This flag is deprecated in favor of --enable-container-network-logs.
- name: --enable-container-network-logs
type: bool
short-summary: Enable container network log collection functionalities on a cluster.
short-summary: Enable container network log collection functionalities on a cluster. Automatically enables --enable-high-log-scale-mode.
- name: --no-ssh-key -x
type: string
short-summary: Do not use or create a local SSH key.
Expand Down Expand Up @@ -297,7 +297,7 @@
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
Expand Down Expand Up @@ -1032,7 +1032,7 @@
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
Expand Down Expand Up @@ -1347,7 +1347,7 @@
short-summary: Enable advanced network flow log collection functionalities on a cluster. This flag is deprecated in favor of --enable-container-network-logs.
- name: --enable-container-network-logs
type: bool
short-summary: Enable container network log collection functionalities on a cluster.
short-summary: Enable container network log collection functionalities on a cluster. Automatically enables --enable-high-log-scale-mode.
- name: --disable-retina-flow-logs
type: bool
short-summary: Disable advanced network flow log collection functionalities on a cluster. This flag is deprecated in favor of --disable-container-network-logs.
Expand Down Expand Up @@ -2816,7 +2816,7 @@
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
Expand Down Expand Up @@ -2889,7 +2889,7 @@
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
Expand Down Expand Up @@ -2977,7 +2977,7 @@
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
short-summary: Enable High Log Scale Mode for Container Logs. Auto-enabled when --enable-container-network-logs is specified.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
Expand Down
22 changes: 11 additions & 11 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def ensure_container_insights_for_monitoring_preview(
data_collection_settings=None,
is_private_cluster=False,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
enable_high_log_scale_mode=None,
):
"""
Preview extension version of ensure_container_insights_for_monitoring that uses REST API
Expand Down Expand Up @@ -1012,10 +1012,10 @@ def aks_create(
enable_azure_monitor_logs=False,
workspace_resource_id=None,
enable_msi_auth_for_monitoring=True,
enable_syslog=False,
enable_syslog=None,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
enable_high_log_scale_mode=None,
aci_subnet_name=None,
appgw_name=None,
appgw_subnet_cidr=None,
Expand Down Expand Up @@ -1275,9 +1275,9 @@ def aks_update(
disable_azure_monitor_logs=False,
workspace_resource_id=None,
enable_msi_auth_for_monitoring=None,
enable_syslog=False,
enable_syslog=None,
data_collection_settings=None,
enable_high_log_scale_mode=False,
enable_high_log_scale_mode=None,
ampls_resource_id=None,
enable_secret_rotation=False,
disable_secret_rotation=False,
Expand Down Expand Up @@ -2758,10 +2758,10 @@ def aks_addon_enable(
enable_msi_auth_for_monitoring=True,
dns_zone_resource_id=None,
dns_zone_resource_ids=None,
enable_syslog=False,
enable_syslog=None,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False
enable_high_log_scale_mode=None
):
return enable_addons(
cmd,
Expand Down Expand Up @@ -2816,10 +2816,10 @@ def aks_addon_update(
enable_msi_auth_for_monitoring=None,
dns_zone_resource_id=None,
dns_zone_resource_ids=None,
enable_syslog=False,
enable_syslog=None,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False
enable_high_log_scale_mode=None
):
instance = client.get(resource_group_name, name)
addon_profiles = instance.addon_profiles
Expand Down Expand Up @@ -2947,10 +2947,10 @@ def aks_enable_addons(
enable_msi_auth_for_monitoring=True,
dns_zone_resource_id=None,
dns_zone_resource_ids=None,
enable_syslog=False,
enable_syslog=None,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
enable_high_log_scale_mode=None,
aks_custom_headers=None,
):
headers = get_aks_custom_headers(aks_custom_headers)
Expand Down
92 changes: 92 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,84 @@ def get_opentelemetry_logs_port(self) -> Union[int, None]:

return opentelemetry_logs_port

def get_enable_high_log_scale_mode(self) -> Union[bool, None]:
"""Obtain the value of enable_high_log_scale_mode.

This method overrides the base class implementation to automatically enable high log scale mode
when container network logs are enabled. It validates that:
1. ACNS (Advanced Container Networking Services) is enabled
2. Monitoring addon is enabled
3. User has not explicitly disabled high log scale mode

:return: bool or None
"""
# Read the original value passed by the command
enable_high_log_scale_mode = self.raw_param.get("enable_high_log_scale_mode")

# Check if container network logs are being enabled
enable_container_network_logs = (
self.raw_param.get("enable_container_network_logs") or
self.raw_param.get("enable_retina_flow_logs")
)

# If container network logs are being enabled, auto-enable high log scale mode
if enable_container_network_logs:
# If user explicitly set enable_high_log_scale_mode to False, raise an error
if enable_high_log_scale_mode is False:
raise MutuallyExclusiveArgumentError(
"Cannot explicitly disable --enable-high-log-scale-mode when "
"--enable-container-network-logs is specified. Container network logs "
"requires high log scale mode to be enabled."
)

# Validate that ACNS is enabled (either being enabled now or already enabled in cluster)
enable_acns = self.raw_param.get("enable_acns")
acns_already_enabled = (
self.mc and
self.mc.network_profile and
self.mc.network_profile.advanced_networking and
self.mc.network_profile.advanced_networking.enabled
)
if not enable_acns and not acns_already_enabled:
raise RequiredArgumentMissingError(
"Container network logs with high log scale mode requires ACNS to be enabled. "
"Please add --enable-acns to your command."
)

# Validate that monitoring addon is enabled (either being enabled now or already enabled in cluster)
addon_consts = self.get_addon_consts()
CONST_MONITORING_ADDON_NAME = addon_consts.get("CONST_MONITORING_ADDON_NAME")

# Check if monitoring is being enabled in the command
enable_addons = self.raw_param.get("enable_addons")
monitoring_being_enabled = enable_addons and "monitoring" in enable_addons

# Check if enabling Azure Monitor logs
enable_azure_monitor_logs = self.raw_param.get("enable_azure_monitor_logs")

# Check if monitoring addon is already enabled in the cluster
monitoring_addon_enabled = False
if self.mc and self.mc.addon_profiles:
if CONST_MONITORING_ADDON_NAME in self.mc.addon_profiles:
monitoring_addon_enabled = self.mc.addon_profiles[CONST_MONITORING_ADDON_NAME].enabled
elif CONST_MONITORING_ADDON_NAME_CAMELCASE in self.mc.addon_profiles:
monitoring_addon_enabled = self.mc.addon_profiles[CONST_MONITORING_ADDON_NAME_CAMELCASE].enabled

if not monitoring_being_enabled and not enable_azure_monitor_logs and not monitoring_addon_enabled:
raise RequiredArgumentMissingError(
"Container network logs with high log scale mode requires the monitoring addon to be enabled. "
"Please add '--enable-addons monitoring' or '--enable-azure-monitor-logs' to your command."
)

# Auto-enable high log scale mode
return True

# If container network logs are not being enabled, return the original value
# Return False if not explicitly set to maintain backward compatibility with base class
if enable_high_log_scale_mode is None:
return False
return enable_high_log_scale_mode

def _get_enable_vpa(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_vpa.
This function supports the option of enable_vpa. When enabled, if both enable_vpa and enable_vpa are
Expand Down Expand Up @@ -3915,6 +3993,13 @@ def set_up_addon_profiles(self, mc: ManagedCluster) -> ManagedCluster:
config["enableRetinaNetworkFlags"] = str(container_network_logs_enabled)
monitoring_addon_profile.config = config

# Trigger validation for high log scale mode when container network logs are enabled.
# This ensures proper error messages are raised before cluster creation if the user
# explicitly disables high log scale mode while enabling container network logs.
if self.context.raw_param.get("enable_container_network_logs") or \
self.context.raw_param.get("enable_retina_flow_logs"):
self.context.get_enable_high_log_scale_mode()

mc.addon_profiles = addon_profiles
return mc

Expand Down Expand Up @@ -5374,6 +5459,13 @@ def update_monitoring_profile_flow_logs(self, mc: ManagedCluster) -> ManagedClus
"""
self._ensure_mc(mc)

# Trigger validation for high log scale mode when container network logs are enabled.
# This ensures proper error messages are raised before cluster update if the user
# explicitly disables high log scale mode while enabling container network logs.
if self.context.raw_param.get("enable_container_network_logs") or \
self.context.raw_param.get("enable_retina_flow_logs"):
self.context.get_enable_high_log_scale_mode()

container_network_logs_enabled = self.context.get_container_network_logs(mc)
if container_network_logs_enabled is not None:
if mc.addon_profiles:
Expand Down
Loading
Loading