Skip to content

Commit 8fd6723

Browse files
committed
Merge branch 'dev' into add-validation-level
2 parents 82ec872 + 41969a2 commit 8fd6723

File tree

96 files changed

+97090
-34423
lines changed

Some content is hidden

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

96 files changed

+97090
-34423
lines changed

.github/policies/resourceManagement.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,11 @@ configuration:
593593
then:
594594
- mentionUsers:
595595
mentionees:
596-
- mksuni
597-
- bgklein
598-
- mscurrell
599596
- dpwatrous
600-
- gingi
601-
- paterasMSFT
597+
- wiboris
602598
- cRui861
599+
- skapur12
600+
- wanghoppe
603601
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
604602
assignMentionees: False
605603
- if:
@@ -1555,7 +1553,6 @@ configuration:
15551553
- mentionUsers:
15561554
mentionees:
15571555
- sourabhguha
1558-
- inesk-vt
15591556
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
15601557
assignMentionees: False
15611558
- if:
@@ -2990,6 +2987,20 @@ configuration:
29902987
- xgithubtriage
29912988
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
29922989
assignMentionees: False
2990+
- if:
2991+
- hasLabel:
2992+
label: Service Attention
2993+
- hasLabel:
2994+
label: Storage Action
2995+
then:
2996+
- mentionUsers:
2997+
mentionees:
2998+
- blueww
2999+
- sshankMSFT
3000+
- golddove
3001+
- S-J-M
3002+
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
3003+
assignMentionees: False
29933004
- if:
29943005
- hasLabel:
29953006
label: Service Attention

linter_exclusions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ aks create:
291291
azure_keyvault_kms_key_vault_resource_id:
292292
rule_exclusions:
293293
- option_length_too_long
294+
node_provisioning_default_pools:
295+
rule_exclusions:
296+
- option_length_too_long
294297
aks enable-addons:
295298
parameters:
296299
workspace_resource_id:
@@ -374,6 +377,9 @@ aks update:
374377
azure_keyvault_kms_key_vault_resource_id:
375378
rule_exclusions:
376379
- option_length_too_long
380+
node_provisioning_default_pools:
381+
rule_exclusions:
382+
- option_length_too_long
377383
aks update-credentials:
378384
parameters:
379385
aad_server_app_secret:

scripts/ci/test_extensions.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ set +e
3232

3333
for ext in $output; do
3434
echo
35-
# Use regex to detect if $ext is in $ignore_list
36-
if [[ $ignore_list =~ $ext ]]; then
35+
# Exact string matching against each item in the ignore list
36+
ignore_match=0
37+
for item in $ignore_list; do
38+
if [ "$ext" = "$item" ]; then
39+
ignore_match=1
40+
break
41+
fi
42+
done
43+
44+
if [ $ignore_match -eq 1 ]; then
3745
echo "Ignore extension: $ext"
3846
continue
3947
fi

src/azure-cli/azure/cli/command_modules/acr/_validators.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
" manifest specifier such as 'myregistry.azurecr.io/hello-world:latest' or"\
2020
" 'myregistry.azurecr.io/hello-world@sha256:abc123'."
2121
BAD_REGISTRY_NAME = "Registry names may contain only alpha numeric characters and must be between 5 and 50 characters"
22+
INVALID_LOGIN_SERVER_SUFFIX = "The login server suffix is not valid for the current cloud. Please try again using"\
23+
" '{}'."
2224

2325
logger = get_logger(__name__)
2426

@@ -104,29 +106,42 @@ def validate_retention_days(namespace):
104106

105107

106108
def validate_registry_name(cmd, namespace):
107-
"""Omit login server endpoint suffix."""
109+
"""Omit login server endpoint suffix and domain name label (DNL) hash if given."""
108110
registry = namespace.registry_name
109111
if registry is None:
110112
return
111113
suffixes = cmd.cli_ctx.cloud.suffixes
112-
dnl_hash = registry.find("-")
113-
114-
if dnl_hash > 0:
115-
logger.warning(
116-
"Registry name is %s. The following suffix '%s' is automatically omitted.",
117-
registry[:dnl_hash],
118-
registry[dnl_hash:])
119-
namespace.registry_name = registry[:dnl_hash]
114+
115+
# Split registry login server into components ['myregistry-dnlhash', '.azurecr.io']
116+
registry_parts = registry.split('.', 1)
117+
trimmed_registry_name = registry_parts[0]
118+
registry_login_server_suffix = '.' + registry_parts[1] if len(registry_parts) > 1 else ''
119+
120+
dnl_hash_index = trimmed_registry_name.find("-")
121+
122+
# Registry name has hyphen but no login server endpoint suffix
123+
if registry_login_server_suffix == '' and dnl_hash_index != -1:
124+
raise InvalidArgumentValueError(BAD_REGISTRY_NAME)
125+
120126
# Some clouds do not define 'acr_login_server_endpoint' (e.g. AzureGermanCloud)
121-
elif hasattr(suffixes, 'acr_login_server_endpoint'):
127+
if hasattr(suffixes, 'acr_login_server_endpoint'):
122128
acr_suffix = suffixes.acr_login_server_endpoint
123-
pos = registry.find(acr_suffix)
124-
if pos > 0:
125-
logger.warning("Registry name is %s. The following suffix '%s' is automatically omitted.",
126-
registry[:pos],
127-
acr_suffix)
128-
namespace.registry_name = registry[:pos]
129-
registry = registry[:pos]
129+
if registry_login_server_suffix.lower() == acr_suffix and registry_login_server_suffix != '':
130+
if dnl_hash_index != -1:
131+
removed_suffix = trimmed_registry_name[dnl_hash_index:] + registry_login_server_suffix
132+
registry_name = trimmed_registry_name[:dnl_hash_index]
133+
else:
134+
removed_suffix = registry_login_server_suffix
135+
registry_name = trimmed_registry_name
136+
logger.warning("Registry name is '%s'. The following suffix '%s' is automatically omitted.",
137+
registry_name,
138+
removed_suffix)
139+
else:
140+
if registry_login_server_suffix != '':
141+
raise InvalidArgumentValueError(INVALID_LOGIN_SERVER_SUFFIX.format(acr_suffix))
142+
registry_name = trimmed_registry_name
143+
namespace.registry_name = registry_name
144+
registry = registry_name
130145

131146
registry = namespace.registry_name
132147
if not re.match(ACR_NAME_VALIDATION_REGEX, registry):

src/azure-cli/azure/cli/command_modules/acr/check_health.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ def _check_registry_health(cmd, registry_name, repository, ignore_errors):
345345
status_validated = _get_registry_status(login_server, registry_name, ignore_errors)
346346
if status_validated:
347347
RoleAssignmentMode = cmd.get_models('RoleAssignmentMode')
348-
registry_abac_enabled = registry.role_assignment_mode == RoleAssignmentMode.ABAC_REPOSITORY_PERMISSIONS
348+
registry_abac_enabled = \
349+
registry and registry.role_assignment_mode == RoleAssignmentMode.ABAC_REPOSITORY_PERMISSIONS
349350
_get_endpoint_and_token_status(cmd, login_server, registry_abac_enabled, repository, ignore_errors)
350351

351352
if cmd.supported_api_version(min_api='2020-11-01-preview', resource_type=ResourceType.MGMT_CONTAINERREGISTRY): # pylint: disable=too-many-nested-blocks

src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_validators.py

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,11 @@
66
import unittest
77
from types import SimpleNamespace
88
from unittest.mock import Mock
9+
from azure.cli.core.azclierror import InvalidArgumentValueError
910
from azure.cli.core.cloud import HARD_CODED_CLOUD_LIST
1011
from azure.cli.command_modules.acr._validators import validate_registry_name
1112

12-
class AcrValidatorsTests(unittest.TestCase):
13-
def test_registry_name_with_dnl_suffix(self):
14-
acr_supported_clouds = [cloud for cloud in HARD_CODED_CLOUD_LIST if cloud.name != 'AzureGermanCloud']
15-
for hard_coded_cloud in acr_supported_clouds:
16-
namespace = SimpleNamespace(
17-
**{
18-
"registry_name": "myacr-dnlhash123",
19-
}
20-
)
21-
cmd = Mock(cli_ctx=Mock(cloud=hard_coded_cloud))
22-
validate_registry_name(cmd, namespace)
23-
self.assertEqual(namespace.registry_name, 'myacr')
24-
13+
class AcrValidatorsTests(unittest.TestCase):
2514
def test_registry_name_with_dnl_suffix_loginserver(self):
2615
namespace = SimpleNamespace(
2716
**{
@@ -33,3 +22,41 @@ def test_registry_name_with_dnl_suffix_loginserver(self):
3322
validate_registry_name(cmd, namespace)
3423
self.assertEqual(namespace.registry_name, 'myacr')
3524

25+
def test_registry_name_valid_inputs(self):
26+
"""Test valid registry names that should pass validation."""
27+
test_cases = [
28+
# (input_registry_name, expected_output)
29+
("validregistry.azurecr.io", "validregistry"),
30+
("myregistry123-dnlhasd234.azurecr.io", "myregistry123"),
31+
("test5chars", "test5chars"),
32+
("a" * 50, "a" * 50), # Maximum length
33+
("registry2024", "registry2024"),
34+
]
35+
36+
azure_public_cloud = HARD_CODED_CLOUD_LIST[0]
37+
cmd = Mock(cli_ctx=Mock(cloud=azure_public_cloud))
38+
39+
for input_name, expected_output in test_cases:
40+
with self.subTest(input_name=input_name):
41+
namespace = SimpleNamespace(registry_name=input_name)
42+
validate_registry_name(cmd, namespace)
43+
self.assertEqual(namespace.registry_name, expected_output)
44+
45+
def test_registry_name_invalid_inputs_should_raise_error(self):
46+
"""Test invalid registry names that should raise InvalidArgumentValueError."""
47+
invalid_inputs = [
48+
"myregistry-hash123", # Has hyphen but no suffix
49+
"test.invalid.suffix", # Invalid suffix
50+
"registry.azurecr.io124567", # Wrong suffix
51+
"my-registry.wrongsuffix.io", # Invalid suffix with hyphen
52+
"78787%^&*(()).azurecr.io" # invalid characters
53+
]
54+
55+
azure_public_cloud = HARD_CODED_CLOUD_LIST[0]
56+
cmd = Mock(cli_ctx=Mock(cloud=azure_public_cloud))
57+
58+
for invalid_input in invalid_inputs:
59+
with self.subTest(invalid_input=invalid_input):
60+
namespace = SimpleNamespace(registry_name=invalid_input)
61+
with self.assertRaises(InvalidArgumentValueError):
62+
validate_registry_name(cmd, namespace)

src/azure-cli/azure/cli/command_modules/acs/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ def __init__(self, cli_ctx=None):
2121

2222
def load_command_table(self, args):
2323
from azure.cli.command_modules.acs.commands import load_command_table
24+
from azure.cli.core.aaz import load_aaz_command_table
25+
try:
26+
from . import aaz
27+
except ImportError:
28+
aaz = None
29+
if aaz:
30+
load_aaz_command_table(
31+
loader=self,
32+
aaz_pkg_name=aaz.__name__,
33+
args=args
34+
)
2435
load_command_table(self, args)
2536
return self.command_table
2637

src/azure-cli/azure/cli/command_modules/acs/_consts.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@
233233
CONST_ARTIFACT_SOURCE_DIRECT = "Direct"
234234
CONST_ARTIFACT_SOURCE_CACHE = "Cache"
235235

236+
# node provisioning mode
237+
CONST_NODE_PROVISIONING_MODE_MANUAL = "Manual"
238+
CONST_NODE_PROVISIONING_MODE_AUTO = "Auto"
239+
240+
# node provisioning default pools
241+
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE = "None"
242+
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO = "Auto"
243+
236244

237245
# consts for decorator pattern
238246
class DecoratorMode(Enum):

src/azure-cli/azure/cli/command_modules/acs/_help.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@
454454
type: string
455455
short-summary: Path to a file containing up to 10 blank line separated certificates. Only valid for Linux nodes.
456456
long-summary: These certificates are used by Custom CA Trust feature and will be added to trust stores of nodes.
457+
- name: --disable-run-command
458+
type: bool
459+
short-summary: Disable Run command feature for the cluster.
457460
- name: --enable-defender
458461
type: bool
459462
short-summary: Enable Microsoft Defender security profile.
@@ -599,6 +602,17 @@
599602
- name: --enable-static-egress-gateway
600603
type: bool
601604
short-summary: Enable Static Egress Gateway addon to the cluster.
605+
- name: --node-provisioning-mode
606+
type: string
607+
short-summary: Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". For more information on "Auto" mode see aka.ms/aks/nap.
608+
- name: --node-provisioning-default-pools
609+
type: string
610+
short-summary: The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
611+
long-summary: |-
612+
The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
613+
Auto: A standard set of Karpenter NodePools are provisioned.
614+
None: No Karpenter NodePools are provisioned.
615+
WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted by that action.
602616
examples:
603617
- name: Create a Kubernetes cluster with an existing SSH public key.
604618
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
@@ -678,6 +692,10 @@
678692
text: az aks create -g MyResourceGroup -n MyManagedCluster --os-sku Ubuntu --max-pods MaxPodsPerNode --network-plugin azure --vnet-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/NodeSubnet --pod-subnet-id /subscriptions/SubID/resourceGroups/AnotherResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/PodSubnet --pod-ip-allocation-mode StaticBlock
679693
- name: Create a kubernetes cluster with VirtualMachines vm set type.
680694
text: az aks create -g MyResourceGroup -n MyManagedCluster --vm-set-type VirtualMachines --vm-sizes "VMSize1,VMSize2" --node-count 3
695+
- name: Create a kubernetes cluster with auto node provisioning.
696+
text: az aks create -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto
697+
- name: Create a kubernetes cluster with auto node provisioning and no default pools.
698+
text: az aks create -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto --node-provisioning-default-pools None
681699
"""
682700

683701
helps['aks update'] = """
@@ -760,6 +778,10 @@
760778
type: string
761779
short-summary: Load balancer backend pool type.
762780
long-summary: Define the LoadBalancer backend pool type of managed inbound backend pool. The nodeIP means the VMs will be attached to the LoadBalancer by adding its private IP address to the backend pool. The nodeIPConfiguration means the VMs will be attached to the LoadBalancer by referencing the backend pool ID in the VM's NIC.
781+
- name: --load-balancer-sku
782+
type: string
783+
short-summary: Azure Load Balancer SKU selection for your cluster. only standard is accepted.
784+
long-summary: Upgrade to Standard Azure Load Balancer SKU for your AKS cluster.
763785
- name: --nat-gateway-managed-outbound-ip-count
764786
type: int
765787
short-summary: NAT gateway managed outbound IP count.
@@ -900,6 +922,12 @@
900922
type: string
901923
short-summary: Path to a file containing up to 10 blank line separated certificates. Only valid for Linux nodes.
902924
long-summary: These certificates are used by Custom CA Trust feature and will be added to trust stores of nodes.
925+
- name: --enable-run-command
926+
type: bool
927+
short-summary: Enable Run command feature for the cluster.
928+
- name: --disable-run-command
929+
type: bool
930+
short-summary: Disable Run command feature for the cluster.
903931
- name: --defender-config
904932
type: string
905933
short-summary: Path to JSON file containing Microsoft Defender profile configurations.
@@ -1069,6 +1097,17 @@
10691097
- name: --migrate-vmas-to-vms
10701098
type: bool
10711099
short-summary: Migrate cluster with VMAS node pool to VMS node pool.
1100+
- name: --node-provisioning-mode
1101+
type: string
1102+
short-summary: Set the node provisioning mode of the cluster. Valid values are "Auto" and "Manual". For more information on "Auto" mode see aka.ms/aks/nap.
1103+
- name: --node-provisioning-default-pools
1104+
type: string
1105+
short-summary: The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
1106+
long-summary: |-
1107+
The set of default Karpenter NodePools configured for node provisioning. Valid values are "Auto" and "None".
1108+
Auto: A standard set of Karpenter NodePools are provisioned.
1109+
None: No Karpenter NodePools are provisioned.
1110+
WARNING: Changing this from Auto to None on an existing cluster will cause the default Karpenter NodePools to be deleted, which will in turn drain and delete the nodes associated with those pools. It is strongly recommended to not do this unless there are idle nodes ready to take the pods evicted by that action.
10721111
examples:
10731112
- name: Reconcile the cluster back to its current state.
10741113
text: az aks update -g MyResourceGroup -n MyManagedCluster
@@ -1128,6 +1167,12 @@
11281167
text: az aks update -g MyResourceGroup -n MyManagedCLuster --enable-vpa
11291168
- name: Disable VPA(Vertical Pod Autoscaler) for an existing kubernetes cluster.
11301169
text: az aks update -g MyResourceGroup -n MyManagedCLuster --disable-vpa
1170+
- name: Update a kubernetes cluster to use auto node provisioning.
1171+
text: az aks update -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto
1172+
- name: Update a kubernetes cluster to use auto node provisioning mode with no default pools.
1173+
text: az aks update -g MyResourceGroup -n MyManagedCluster --node-provisioning-mode Auto --node-provisioning-default-pools None
1174+
- name: Upgrade load balancer sku to standard
1175+
text: az aks update --load-balancer-sku standard -g MyResourceGroup -n MyManagedCluster
11311176
"""
11321177

11331178
helps['aks delete'] = """

0 commit comments

Comments
 (0)