Skip to content

Commit 359a5bb

Browse files
author
chenxi
committed
Merge branch 'main' into feature/eas-llm-setup
2 parents 2d5c55f + 021dc93 commit 359a5bb

File tree

758 files changed

+135791
-44835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

758 files changed

+135791
-44835
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* `az aks update`: Add new parameter `--kms-infrastructure-encryption` to enable KMS infrastructure encryption on an existing cluster.
15+
16+
18.0.0b44
17+
+++++++
18+
* Vendor new SDK and bump API version to 2025-08-02-preview.
19+
* Pre-deprecate `--enable-custom-ca-trust` and `--disable-custom-ca-trust` in `az aks create`, `az aks update` commands.
20+
* Hide `--enable-managed-system-pool` parameter for `az aks create` for now, as the feature is not ready yet.
21+
22+
18.0.0b43
23+
+++++++
24+
* Fix `--localdns-config` parameter to handle null values and case-insensitive JSON keys in DNS override sections, preventing crashes with malformed localdns configuration files.
25+
* Enhance `build_override` function to validate dictionary types and only initialize DNS overrides when present in localdns configuration (case-insensitive).
26+
* Refactor `build_localdns_profile` function to eliminate code duplication between AgentPool add and update operations.
1427

1528
18.0.0b42
1629
+++++++
@@ -37,7 +50,7 @@ Pending
3750
* Add option `AzureLinuxOSGuard` and `AzureLinux3OSGuard` to `--os-sku` for `az aks nodepool add` and `az aks nodepool update`.
3851
* Add machine command `az aks machine add` to add a machine to an existing machine pool.
3952
* Add blue-green upgrade strategy support for AKS node pools:
40-
- `az aks nodepool add/update/upgrade`: Add `--upgrade-strategy` parameter to switch between rolling and blue-green nodepool upgrades.
53+
- `az aks nodepool add/update/upgrade`: Add `--upgrade-strategy` parameter to switch between rolling and blue-green nodepool upgrades.
4154
- `az aks nodepool add/update/upgrade`: Add `--drain-batch-size`, `--drain-timeout-bg`, `--batch-soak-duration`, `--final-soak-duration` parameters to configure blue-green upgrade settings.
4255

4356
18.0.0b38

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,10 @@
11101110
- name: --azure-keyvault-kms-key-vault-resource-id
11111111
type: string
11121112
short-summary: Resource ID of Azure Key Vault.
1113+
- name: --kms-infrastructure-encryption
1114+
type: string
1115+
short-summary: Enable encryption at rest of Kubernetes resource objects using service-managed keys.
1116+
long-summary: Enable infrastructure encryption for Kubernetes resource objects. This feature provides encryption at rest for cluster secrets and configuration using service-managed keys. For more information see https://aka.ms/aks/kubernetesResourceObjectEncryption.
11131117
- name: --enable-image-cleaner
11141118
type: bool
11151119
short-summary: Enable ImageCleaner Service.

src/aks-preview/azext_aks_preview/_helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ def process_dns_overrides(overrides_dict, target_dict, build_override_func):
460460
:param target_dict: Target dictionary to populate with processed overrides
461461
:param build_override_func: Function to build override objects from dict values
462462
"""
463+
if not isinstance(overrides_dict, dict):
464+
raise InvalidArgumentValueError(
465+
f"Expected a dictionary for DNS overrides, but got {type(overrides_dict).__name__}: {overrides_dict}"
466+
)
463467
if overrides_dict is not None:
464468
for key, value in overrides_dict.items():
465469
if value is not None:

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,10 @@ def load_arguments(self, _):
11271127
# virtual machines
11281128
c.argument("vm_sizes", is_preview=True)
11291129
c.argument("enable_imds_restriction", action="store_true", is_preview=True)
1130-
c.argument("enable_managed_system_pool", action="store_true", is_preview=True)
1130+
c.argument("enable_managed_system_pool",
1131+
action="store_true",
1132+
is_preview=True,
1133+
deprecate_info=c.deprecate(target="--enable-managed-system-pool", hide=True))
11311134
c.argument("enable_upstream_kubescheduler_user_configuration", action="store_true", is_preview=True)
11321135

11331136
with self.argument_context("aks update") as c:
@@ -1264,6 +1267,11 @@ def load_arguments(self, _):
12641267
"azure_keyvault_kms_key_vault_resource_id",
12651268
validator=validate_azure_keyvault_kms_key_vault_resource_id,
12661269
)
1270+
c.argument(
1271+
"kms_infrastructure_encryption",
1272+
arg_type=get_enum_type(["Enabled", "Disabled"]),
1273+
is_preview=True,
1274+
)
12671275
c.argument("http_proxy_config")
12681276
c.argument(
12691277
"bootstrap_artifact_source",

src/aks-preview/azext_aks_preview/agentpool_decorator.py

Lines changed: 74 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -241,65 +241,6 @@ def get_workload_runtime(self) -> Union[str, None]:
241241
# this parameter does not need validation
242242
return workload_runtime
243243

244-
def _get_enable_custom_ca_trust(self, enable_validation: bool = False) -> bool:
245-
"""Internal function to obtain the value of enable_custom_ca_trust.
246-
247-
This function supports the option of enable_validation. When enabled, if both enable_custom_ca_trust and
248-
disable_custom_ca_trust are specified, raise a MutuallyExclusiveArgumentError.
249-
250-
:return: bool
251-
"""
252-
# read the original value passed by the command
253-
enable_custom_ca_trust = self.raw_param.get("enable_custom_ca_trust")
254-
# In create mode, try to read the property value corresponding to the parameter from the `agentpool` object
255-
if self.decorator_mode == DecoratorMode.CREATE:
256-
if self.agentpool and self.agentpool.enable_custom_ca_trust is not None:
257-
enable_custom_ca_trust = self.agentpool.enable_custom_ca_trust
258-
259-
# this parameter does not need dynamic completion
260-
# validation
261-
if enable_validation:
262-
if enable_custom_ca_trust and self._get_disable_custom_ca_trust(enable_validation=False):
263-
raise MutuallyExclusiveArgumentError(
264-
'Cannot specify "--enable-custom-ca-trust" and "--disable-custom-ca-trust" at the same time'
265-
)
266-
return enable_custom_ca_trust
267-
268-
def get_enable_custom_ca_trust(self) -> bool:
269-
"""Obtain the value of enable_custom_ca_trust.
270-
271-
:return: bool
272-
"""
273-
return self._get_enable_custom_ca_trust(enable_validation=True)
274-
275-
def _get_disable_custom_ca_trust(self, enable_validation: bool = False) -> bool:
276-
"""Internal function to obtain the value of disable_custom_ca_trust.
277-
278-
This function supports the option of enable_validation. When enabled, if both enable_custom_ca_trust and
279-
disable_custom_ca_trust are specified, raise a MutuallyExclusiveArgumentError.
280-
281-
:return: bool
282-
"""
283-
# read the original value passed by the command
284-
disable_custom_ca_trust = self.raw_param.get("disable_custom_ca_trust")
285-
# This option is not supported in create mode, so its value is not read from `agentpool`.
286-
287-
# this parameter does not need dynamic completion
288-
# validation
289-
if enable_validation:
290-
if disable_custom_ca_trust and self._get_enable_custom_ca_trust(enable_validation=False):
291-
raise MutuallyExclusiveArgumentError(
292-
'Cannot specify "--enable-custom-ca-trust" and "--disable-custom-ca-trust" at the same time'
293-
)
294-
return disable_custom_ca_trust
295-
296-
def get_disable_custom_ca_trust(self) -> bool:
297-
"""Obtain the value of disable_custom_ca_trust.
298-
299-
:return: bool
300-
"""
301-
return self._get_disable_custom_ca_trust(enable_validation=True)
302-
303244
def _get_disable_windows_outbound_nat(self) -> bool:
304245
"""Internal function to obtain the value of disable_windows_outbound_nat.
305246
@@ -940,6 +881,78 @@ def get_localdns_profile(self):
940881
return profile
941882
return None
942883

884+
def build_localdns_profile(self, agentpool: AgentPool) -> AgentPool:
885+
"""Build local DNS profile for the AgentPool object if provided via --localdns-config."""
886+
localdns_profile = self.get_localdns_profile()
887+
kube_dns_overrides, vnet_dns_overrides = None, None
888+
889+
if localdns_profile is not None:
890+
def find_keys_case_insensitive(dictionary, target_keys):
891+
"""Find multiple keys case-insensitively and return a dict mapping target_key -> actual_key"""
892+
result = {}
893+
lowered_keys = {key.lower(): key for key in dictionary.keys()}
894+
for target_key in target_keys:
895+
lowered_target = target_key.lower()
896+
if lowered_target in lowered_keys:
897+
result[target_key] = lowered_keys[lowered_target]
898+
else:
899+
result[target_key] = None
900+
return result
901+
902+
def build_override(override_dict):
903+
if not isinstance(override_dict, dict):
904+
raise InvalidArgumentValueError(
905+
f"Expected a dictionary for DNS override settings,"
906+
f" but got {type(override_dict).__name__}: {override_dict}"
907+
)
908+
camel_to_snake_case = {
909+
"queryLogging": "query_logging",
910+
"protocol": "protocol",
911+
"forwardDestination": "forward_destination",
912+
"forwardPolicy": "forward_policy",
913+
"maxConcurrent": "max_concurrent",
914+
"cacheDurationInSeconds": "cache_duration_in_seconds",
915+
"serveStaleDurationInSeconds": "serve_stale_duration_in_seconds",
916+
"serveStale": "serve_stale",
917+
}
918+
valid_keys = set(camel_to_snake_case.values())
919+
filtered = {}
920+
for k, v in override_dict.items():
921+
if k in camel_to_snake_case:
922+
filtered[camel_to_snake_case[k]] = v
923+
elif k in valid_keys:
924+
filtered[k] = v
925+
return self.models.LocalDNSOverride(**filtered)
926+
927+
# Build kubeDNSOverrides and vnetDNSOverrides from the localdns_profile
928+
key_mappings = find_keys_case_insensitive(localdns_profile, ["kubeDNSOverrides", "vnetDNSOverrides"])
929+
actual_kube_key = key_mappings["kubeDNSOverrides"]
930+
if actual_kube_key:
931+
logger.debug("Found kubeDNSOverrides key as: %s", actual_kube_key)
932+
kube_dns_overrides = {}
933+
process_dns_overrides(
934+
localdns_profile.get(actual_kube_key),
935+
kube_dns_overrides,
936+
build_override
937+
)
938+
939+
actual_vnet_key = key_mappings["vnetDNSOverrides"]
940+
if actual_vnet_key:
941+
logger.debug("Found vnetDNSOverrides key as: %s", actual_vnet_key)
942+
vnet_dns_overrides = {}
943+
process_dns_overrides(
944+
localdns_profile.get(actual_vnet_key),
945+
vnet_dns_overrides,
946+
build_override
947+
)
948+
949+
agentpool.local_dns_profile = self.models.LocalDNSProfile(
950+
mode=localdns_profile.get("mode"),
951+
kube_dns_overrides=kube_dns_overrides,
952+
vnet_dns_overrides=vnet_dns_overrides,
953+
)
954+
return agentpool
955+
943956
def get_node_count_and_enable_cluster_autoscaler_min_max_count_vms(
944957
self,
945958
) -> Tuple[int, bool, Union[int, None], Union[int, None]]:
@@ -1195,16 +1208,6 @@ def set_up_gpu_properties(self, agentpool: AgentPool) -> AgentPool:
11951208
agentpool.workload_runtime = self.context.get_workload_runtime()
11961209
return agentpool
11971210

1198-
def set_up_custom_ca_trust(self, agentpool: AgentPool) -> AgentPool:
1199-
"""Set up custom ca trust property for the AgentPool object.
1200-
1201-
:return: the AgentPool object
1202-
"""
1203-
self._ensure_agentpool(agentpool)
1204-
1205-
agentpool.enable_custom_ca_trust = self.context.get_enable_custom_ca_trust()
1206-
return agentpool
1207-
12081211
def set_up_agentpool_windows_profile(self, agentpool: AgentPool) -> AgentPool:
12091212
"""Set up windows profile for the AgentPool object.
12101213
@@ -1452,49 +1455,7 @@ def set_up_managed_system_mode(self, agentpool: AgentPool) -> AgentPool:
14521455
def set_up_localdns_profile(self, agentpool: AgentPool) -> AgentPool:
14531456
"""Set up local DNS profile for the AgentPool object if provided via --localdns-config."""
14541457
self._ensure_agentpool(agentpool)
1455-
localdns_profile = self.context.get_localdns_profile()
1456-
if localdns_profile is not None:
1457-
kube_dns_overrides = {}
1458-
vnet_dns_overrides = {}
1459-
1460-
def build_override(override_dict):
1461-
camel_to_snake_case = {
1462-
"queryLogging": "query_logging",
1463-
"protocol": "protocol",
1464-
"forwardDestination": "forward_destination",
1465-
"forwardPolicy": "forward_policy",
1466-
"maxConcurrent": "max_concurrent",
1467-
"cacheDurationInSeconds": "cache_duration_in_seconds",
1468-
"serveStaleDurationInSeconds": "serve_stale_duration_in_seconds",
1469-
"serveStale": "serve_stale",
1470-
}
1471-
valid_keys = set(camel_to_snake_case.values())
1472-
filtered = {}
1473-
for k, v in override_dict.items():
1474-
if k in camel_to_snake_case:
1475-
filtered[camel_to_snake_case[k]] = v
1476-
elif k in valid_keys:
1477-
filtered[k] = v
1478-
return self.models.LocalDNSOverride(**filtered)
1479-
1480-
# Build kubeDNSOverrides and vnetDNSOverrides from the localdns_profile
1481-
process_dns_overrides(
1482-
localdns_profile.get("kubeDNSOverrides"),
1483-
kube_dns_overrides,
1484-
build_override
1485-
)
1486-
process_dns_overrides(
1487-
localdns_profile.get("vnetDNSOverrides"),
1488-
vnet_dns_overrides,
1489-
build_override
1490-
)
1491-
1492-
agentpool.local_dns_profile = self.models.LocalDNSProfile(
1493-
mode=localdns_profile.get("mode"),
1494-
kube_dns_overrides=kube_dns_overrides,
1495-
vnet_dns_overrides=vnet_dns_overrides,
1496-
)
1497-
return agentpool
1458+
return self.context.build_localdns_profile(agentpool)
14981459

14991460
def construct_agentpool_profile_preview(self) -> AgentPool:
15001461
"""The overall controller used to construct the preview AgentPool profile.
@@ -1518,8 +1479,6 @@ def construct_agentpool_profile_preview(self) -> AgentPool:
15181479
agentpool = self.set_up_preview_vm_properties(agentpool)
15191480
# set up message of the day
15201481
agentpool = self.set_up_motd(agentpool)
1521-
# set up custom ca trust
1522-
agentpool = self.set_up_custom_ca_trust(agentpool)
15231482
# set up agentpool windows profile
15241483
agentpool = self.set_up_agentpool_windows_profile(agentpool)
15251484
# set up agentpool network profile
@@ -1672,20 +1631,6 @@ def init_context(self) -> None:
16721631
self.agentpool_decorator_mode,
16731632
)
16741633

1675-
def update_custom_ca_trust(self, agentpool: AgentPool) -> AgentPool:
1676-
"""Update custom ca trust property for the AgentPool object.
1677-
1678-
:return: the AgentPool object
1679-
"""
1680-
self._ensure_agentpool(agentpool)
1681-
1682-
if self.context.get_enable_custom_ca_trust():
1683-
agentpool.enable_custom_ca_trust = True
1684-
1685-
if self.context.get_disable_custom_ca_trust():
1686-
agentpool.enable_custom_ca_trust = False
1687-
return agentpool
1688-
16891634
def update_network_profile(self, agentpool: AgentPool) -> AgentPool:
16901635
self._ensure_agentpool(agentpool)
16911636

@@ -1794,49 +1739,7 @@ def update_fips_image(self, agentpool: AgentPool) -> AgentPool:
17941739
def update_localdns_profile(self, agentpool: AgentPool) -> AgentPool:
17951740
"""Update local DNS profile for the AgentPool object if provided via --localdns-config."""
17961741
self._ensure_agentpool(agentpool)
1797-
localdns_profile = self.context.get_localdns_profile()
1798-
if localdns_profile is not None:
1799-
kube_dns_overrides = {}
1800-
vnet_dns_overrides = {}
1801-
1802-
def build_override(override_dict):
1803-
camel_to_snake_case = {
1804-
"queryLogging": "query_logging",
1805-
"protocol": "protocol",
1806-
"forwardDestination": "forward_destination",
1807-
"forwardPolicy": "forward_policy",
1808-
"maxConcurrent": "max_concurrent",
1809-
"cacheDurationInSeconds": "cache_duration_in_seconds",
1810-
"serveStaleDurationInSeconds": "serve_stale_duration_in_seconds",
1811-
"serveStale": "serve_stale",
1812-
}
1813-
valid_keys = set(camel_to_snake_case.values())
1814-
filtered = {}
1815-
for k, v in override_dict.items():
1816-
if k in camel_to_snake_case:
1817-
filtered[camel_to_snake_case[k]] = v
1818-
elif k in valid_keys:
1819-
filtered[k] = v
1820-
return self.models.LocalDNSOverride(**filtered)
1821-
1822-
# Build kubeDNSOverrides and vnetDNSOverrides from the localdns_profile
1823-
process_dns_overrides(
1824-
localdns_profile.get("kubeDNSOverrides"),
1825-
kube_dns_overrides,
1826-
build_override
1827-
)
1828-
process_dns_overrides(
1829-
localdns_profile.get("vnetDNSOverrides"),
1830-
vnet_dns_overrides,
1831-
build_override
1832-
)
1833-
1834-
agentpool.local_dns_profile = self.models.LocalDNSProfile(
1835-
mode=localdns_profile.get("mode"),
1836-
kube_dns_overrides=kube_dns_overrides,
1837-
vnet_dns_overrides=vnet_dns_overrides,
1838-
)
1839-
return agentpool
1742+
return self.context.build_localdns_profile(agentpool)
18401743

18411744
def update_upgrade_strategy(self, agentpool: AgentPool) -> AgentPool:
18421745
"""Update upgrade strategy for the AgentPool object.
@@ -1871,9 +1774,6 @@ def update_agentpool_profile_preview(self, agentpools: List[AgentPool] = None) -
18711774
setattr(agentpool, attr, None)
18721775
return agentpool
18731776

1874-
# update custom ca trust
1875-
agentpool = self.update_custom_ca_trust(agentpool)
1876-
18771777
# update network profile
18781778
agentpool = self.update_network_profile(agentpool)
18791779

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ def aks_update(
865865
azure_keyvault_kms_key_id=None,
866866
azure_keyvault_kms_key_vault_network_access=None,
867867
azure_keyvault_kms_key_vault_resource_id=None,
868+
kms_infrastructure_encryption=None,
868869
http_proxy_config=None,
869870
disable_http_proxy=False,
870871
enable_http_proxy=False,

0 commit comments

Comments
 (0)