Skip to content

Commit da3cf38

Browse files
committed
Merge branch 'adsandor/breakmsg' of https://github.com/Sandido/azure-cli-extensions into adsandor/breakmsg
2 parents 6c629e4 + 5db779e commit da3cf38

File tree

846 files changed

+207276
-112882
lines changed

Some content is hidden

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

846 files changed

+207276
-112882
lines changed

.githooks/pre-commit

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
#!/usr/bin/env sh
2-
":" //; if command -v pwsh >/dev/null 2>&1; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-commit.ps1; else sh .githooks/pre-commit.sh; fi; exit $? # Try PowerShell Core first, then sh on Unix
3-
":" //; exit # Skip rest on Unix
42

5-
@echo off
6-
powershell -NoProfile -Command "if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7-
if %errorlevel% equ 0 (
8-
powershell -ExecutionPolicy Bypass -File .githooks\pre-commit.ps1
9-
) else (
10-
echo Error: PowerShell is not available. Please install PowerShell.
11-
exit /b 1
12-
)
13-
exit /b %errorlevel%
3+
# Check if running in Windows
4+
if [ -n "$COMSPEC" ]; then
5+
# Windows section - Execute directly with PowerShell
6+
powershell -NoProfile -Command "
7+
if (Get-Command powershell -ErrorAction SilentlyContinue) {
8+
Write-Host 'PowerShell found, executing pre-commit.ps1...'
9+
powershell -ExecutionPolicy Bypass -File '.githooks\pre-commit.ps1'
10+
exit $LASTEXITCODE
11+
} else {
12+
Write-Host 'Error: PowerShell is not available. Please install PowerShell.'
13+
exit 1
14+
}
15+
"
16+
echo "Exiting with status $?"
17+
exit $?
18+
else
19+
# Unix-like system section
20+
echo "Unix-like system found, executing pre-commit.sh..."
21+
sh .githooks/pre-commit.sh
22+
echo "Exiting with status $?"
23+
exit $?
24+
fi

.githooks/pre-push

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
#!/usr/bin/env sh
2-
":" //; if command -v pwsh >/dev/null 2>&1; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-push.ps1; else sh .githooks/pre-push.sh; fi; exit $? # Try PowerShell Core first, then sh on Unix
3-
":" //; exit # Skip rest on Unix
42

5-
@echo off
6-
powershell -NoProfile -Command "if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7-
if %errorlevel% equ 0 (
8-
powershell -ExecutionPolicy Bypass -File .githooks\pre-push.ps1
9-
) else (
10-
echo Error: PowerShell is not available. Please install PowerShell.
11-
exit /b 1
12-
)
13-
exit /b %errorlevel%
3+
# Check if running in Windows
4+
if [ -n "$COMSPEC" ]; then
5+
# Windows section - Execute directly with PowerShell
6+
powershell -NoProfile -Command "
7+
if (Get-Command powershell -ErrorAction SilentlyContinue) {
8+
Write-Host 'PowerShell found, executing pre-push.ps1...'
9+
powershell -ExecutionPolicy Bypass -File '.githooks\pre-push.ps1'
10+
exit $LASTEXITCODE
11+
} else {
12+
Write-Host 'Error: PowerShell is not available. Please install PowerShell.'
13+
exit 1
14+
}
15+
"
16+
echo "Exiting with status $?"
17+
exit $?
18+
else
19+
# Unix-like system section
20+
echo "Unix-like system found, executing pre-push.sh..."
21+
sh .githooks/pre-push.sh
22+
echo "Exiting with status $?"
23+
exit $?
24+
fi

.githooks/pre-push.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ if ($AZURE_CLI_FOLDER) {
6666
Write-Host "Would you like to automatically rebase and setup? [Y/n]" -ForegroundColor Yellow
6767

6868
try {
69-
$reader = [System.IO.StreamReader]::new("CON")
70-
$input = $reader.ReadLine()
69+
$input = Read-Host
70+
if ([string]::IsNullOrEmpty($input)) {
71+
$input = "Y"
72+
}
7173
} catch {
7274
Write-Host "Error reading input. Aborting push..." -ForegroundColor Red
7375
exit 1

.github/workflows/AddIssueComment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44

55
jobs:
66
thank-user:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-latest
88
permissions:
99
issues: write
1010
name: Say thanks for the Issue

.github/workflows/AddIssueCommentWithLabel.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
comment-non-security:
88
if: contains(github.event.issue.labels.*.name, 'non-security')
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
1010
permissions:
1111
issues: write
1212
name: Comment on issue

src/aks-preview/HISTORY.rst

+16-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ If there is no rush to release a new version, please just add a description of t
99

1010
To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.
1111

12+
Pending
13+
+++++++
14+
* Vendor new SDK and bump API version to 2024-10-02-preview.
15+
16+
13.0.0b8
17+
+++++++
18+
* `az aks create/update``: Update recording rule group create logic for managed prometheus addon
19+
20+
13.0.0b7
21+
+++++++
22+
* Add `--max-unavailable` to the `az aks nodepool add/update/upgrade` commands.
23+
24+
13.0.0b6
25+
+++++++
26+
* `az aks create/update`: Update parameter description of `--custom-ca-certificates`.
27+
1228
13.0.0b5
1329
+++++++
1430
* `az aks create/az aks nodepool add`: Emit error message when using `--asg-ids` alone without `--allowed-host-ports`.
@@ -24,9 +40,6 @@ To release a new version, please select a new version number (usually plus 1 to
2440
13.0.0b2
2541
+++++++
2642
* `az aks create/update`: Update advanced container networking service (acns) with 2024-09-02-preview API version enablement.
27-
28-
Pending
29-
+++++++
3043
* Vendor new SDK and bump API version to 2024-09-02-preview.
3144

3245
13.0.0b1

src/aks-preview/README.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ Released version and adopted API version
181181
* - 9.0.0b2 ~ 13.0.0b1
182182
- 2024-07-02-preview
183183
-
184-
* - 13.0.0b2 ~ latest
184+
* - 13.0.0b2 ~ 13.0.0b7
185185
- 2024-09-02-preview
186186
-
187+
* - 13.0.0b8 ~ latest
188+
- 2024-10-02-preview
189+
-

src/aks-preview/azext_aks_preview/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def register_aks_preview_resource_type():
1616
register_resource_type(
1717
"latest",
1818
CUSTOM_MGMT_AKS_PREVIEW,
19-
SDKProfile("2024-09-02-preview", {"container_services": "2017-07-01"}),
19+
SDKProfile("2024-10-02-preview", {"container_services": "2017-07-01"}),
2020
)
2121

2222

src/aks-preview/azext_aks_preview/_help.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
- name: --ca-certs --custom-ca-trust-certificates
516516
type: string
517517
short-summary: Path to a file containing up to 10 blank line separated certificates. Only valid for linux nodes.
518-
long-summary: These certificates are used by Custom CA Trust features and will be added to trust stores of nodes. Requires Custom CA Trust to be enabled on the node.
518+
long-summary: These certificates are used by Custom CA Trust features and will be added to trust stores of nodes.
519519
- name: --enable-keda
520520
type: bool
521521
short-summary: Enable KEDA workload auto-scaler.
@@ -1186,7 +1186,7 @@
11861186
- name: --ca-certs --custom-ca-trust-certificates
11871187
type: string
11881188
short-summary: Path to a file containing up to 10 blank line separated certificates. Only valid for linux nodes.
1189-
long-summary: These certificates are used by Custom CA Trust features and will be added to trust stores of nodes. Requires Custom CA Trust to be enabled on the node.
1189+
long-summary: These certificates are used by Custom CA Trust features and will be added to trust stores of nodes.
11901190
- name: --safeguards-level
11911191
type: string
11921192
short-summary: The deployment safeguards Level. Accepted Values are [Off, Warning, Enforcement]. Requires azure policy addon to be enabled
@@ -1775,6 +1775,9 @@
17751775
- name: --node-soak-duration
17761776
type: int
17771777
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
1778+
- name: --max-unavailable
1779+
type: string
1780+
short-summary: The maximum number or percentage of nodes that can be simultaneously unavailable during upgrade. When specified, it represents the number or percent used, eg. 1 or 5%
17781781
- name: --kubelet-config
17791782
type: string
17801783
short-summary: Kubelet configurations for agent nodes.
@@ -1911,6 +1914,9 @@
19111914
- name: --node-soak-duration
19121915
type: int
19131916
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
1917+
- name: --max-unavailable
1918+
type: string
1919+
short-summary: The maximum number or percentage of nodes that can be simultaneously unavailable during upgrade. When specified, it represents the number or percent used, eg. 1 or 5%
19141920
- name: --aks-custom-headers
19151921
type: string
19161922
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
@@ -1960,6 +1966,9 @@
19601966
- name: --node-soak-duration
19611967
type: int
19621968
short-summary: The amount of time (in minutes) to wait after draining a node and before reimaging it and moving on to next node.
1969+
- name: --max-unavailable
1970+
type: string
1971+
short-summary: The maximum number or percentage of nodes that can be simultaneously unavailable during upgrade. When specified, it represents the number or percent used, eg. 1 or 5%
19631972
- name: --mode
19641973
type: string
19651974
short-summary: The mode for a node pool which defines a node pool's primary function. If set as "System", AKS prefers system pods scheduling to node pools with mode `System`. Learn more at https://aka.ms/aks/nodepool/mode.

src/aks-preview/azext_aks_preview/_params.py

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
validate_custom_endpoints,
195195
validate_bootstrap_container_registry_resource_id,
196196
validate_gateway_prefix_size,
197+
validate_max_unavailable,
197198
)
198199
from azext_aks_preview.azurecontainerstorage._consts import (
199200
CONST_ACSTOR_ALL,
@@ -1469,6 +1470,7 @@ def load_arguments(self, _):
14691470
c.argument("drain_timeout", type=int)
14701471
c.argument("node_soak_duration", type=int)
14711472
c.argument("undrainable_node_behavior")
1473+
c.argument("max_unavailable", validator=validate_max_unavailable)
14721474
c.argument("mode", arg_type=get_enum_type(node_mode_types))
14731475
c.argument("scale_down_mode", arg_type=get_enum_type(scale_down_modes))
14741476
c.argument("max_pods", type=int, options_list=["--max-pods", "-m"])
@@ -1587,6 +1589,7 @@ def load_arguments(self, _):
15871589
c.argument("drain_timeout", type=int)
15881590
c.argument("node_soak_duration", type=int)
15891591
c.argument("undrainable_node_behavior")
1592+
c.argument("max_unavailable", validator=validate_max_unavailable)
15901593
c.argument("mode", arg_type=get_enum_type(node_mode_types))
15911594
c.argument("scale_down_mode", arg_type=get_enum_type(scale_down_modes))
15921595
# extensions
@@ -1657,6 +1660,7 @@ def load_arguments(self, _):
16571660
c.argument("drain_timeout", type=int)
16581661
c.argument("node_soak_duration", type=int)
16591662
c.argument("undrainable_node_behavior")
1663+
c.argument("max_unavailable", validator=validate_max_unavailable)
16601664
c.argument("snapshot_id", validator=validate_snapshot_id)
16611665
c.argument(
16621666
"yes",

src/aks-preview/azext_aks_preview/_validators.py

+16
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,22 @@ def validate_max_surge(namespace):
464464
raise CLIError("--max-surge should be an int or percentage")
465465

466466

467+
def validate_max_unavailable(namespace):
468+
"""validates parameters max unavailable are positive integers or percents."""
469+
if namespace.max_unavailable is None:
470+
return
471+
int_or_percent = namespace.max_unavailable
472+
if int_or_percent.endswith('%'):
473+
int_or_percent = int_or_percent.rstrip('%')
474+
475+
try:
476+
if int(int_or_percent) < 0:
477+
raise CLIError("--max-unavailable must be positive")
478+
except ValueError:
479+
# pylint: disable=raise-missing-from
480+
raise CLIError("--max-unavailable should be an int or percentage")
481+
482+
467483
def validate_assign_identity(namespace):
468484
if namespace.assign_identity is not None:
469485
if namespace.assign_identity == '':

src/aks-preview/azext_aks_preview/agentpool_decorator.py

+28
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,26 @@ def get_undrainable_node_behavior(self) -> str:
477477
# this parameter does not need validation
478478
return undrainable_node_behavior
479479

480+
def get_max_unavailable(self) -> str:
481+
"""Obtain the value of max_unavailable.
482+
483+
:return: string
484+
"""
485+
# read the original value passed by the command
486+
max_unavailable = self.raw_param.get("max_unavailable")
487+
# In create mode, try to read the property value corresponding to the parameter from the `agentpool` object
488+
if self.decorator_mode == DecoratorMode.CREATE:
489+
if (
490+
self.agentpool and
491+
self.agentpool.upgrade_settings and
492+
self.agentpool.upgrade_settings.max_unavailable is not None
493+
):
494+
max_unavailable = self.agentpool.upgrade_settings.max_unavailable
495+
496+
# this parameter does not need dynamic completion
497+
# this parameter does not need validation
498+
return max_unavailable
499+
480500
def get_enable_artifact_streaming(self) -> bool:
481501
"""Obtain the value of enable_artifact_streaming.
482502
:return: bool
@@ -1042,6 +1062,10 @@ def set_up_upgrade_settings(self, agentpool: AgentPool) -> AgentPool:
10421062
if undrainable_node_behavior:
10431063
upgrade_settings.undrainable_node_behavior = undrainable_node_behavior
10441064

1065+
max_unavailable = self.context.get_max_unavailable()
1066+
if max_unavailable:
1067+
upgrade_settings.max_unavailable = max_unavailable
1068+
10451069
agentpool.upgrade_settings = upgrade_settings
10461070
return agentpool
10471071

@@ -1267,6 +1291,10 @@ def update_upgrade_settings(self, agentpool: AgentPool) -> AgentPool:
12671291
upgrade_settings.undrainable_node_behavior = undrainable_node_behavior
12681292
agentpool.upgrade_settings = upgrade_settings
12691293

1294+
max_unavailable = self.context.get_max_unavailable()
1295+
if max_unavailable:
1296+
upgrade_settings.max_unavailable = max_unavailable
1297+
12701298
return agentpool
12711299

12721300
def update_agentpool(self, agentpool: AgentPool) -> AgentPool:

src/aks-preview/azext_aks_preview/azurecontainerstorage/_helpers.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,25 @@ def get_extension_installed_and_cluster_configs(
152152
cluster_name,
153153
agentpool_profiles
154154
) -> Tuple[bool, bool, bool, bool, bool, float, str, str]:
155-
client_factory = get_k8s_extension_module(CONST_K8S_EXTENSION_CLIENT_FACTORY_MOD_NAME)
156-
client = client_factory.cf_k8s_extension_operation(cmd.cli_ctx)
157-
k8s_extension_custom_mod = get_k8s_extension_module(CONST_K8S_EXTENSION_CUSTOM_MOD_NAME)
158-
is_extension_installed = False
159-
is_elasticSan_enabled = False
160-
is_azureDisk_enabled = False
161-
is_ephemeralDisk_nvme_enabled = False
162-
is_ephemeralDisk_localssd_enabled = False
163-
ephemeral_disk_volume_type = CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY
164-
perf_tier = CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD
165-
resource_cpu_value = -1
155+
156+
try:
157+
client_factory = get_k8s_extension_module(CONST_K8S_EXTENSION_CLIENT_FACTORY_MOD_NAME)
158+
client = client_factory.cf_k8s_extension_operation(cmd.cli_ctx)
159+
k8s_extension_custom_mod = get_k8s_extension_module(CONST_K8S_EXTENSION_CUSTOM_MOD_NAME)
160+
is_extension_installed = False
161+
is_elasticSan_enabled = False
162+
is_azureDisk_enabled = False
163+
is_ephemeralDisk_nvme_enabled = False
164+
is_ephemeralDisk_localssd_enabled = False
165+
ephemeral_disk_volume_type = CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY
166+
perf_tier = CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD
167+
resource_cpu_value = -1
168+
except UnknownError as e:
169+
logger.error(f"\nError fetching k8s extension module: {e}")
170+
return False, False, False, False, False, -1, "", ""
171+
except Exception as ex:
172+
logger.error(f"\Exception occurred while fetching k8s extension module: {ex}")
173+
return False, False, False, False, False, -1, "", ""
166174

167175
try:
168176
extension = k8s_extension_custom_mod.show_k8s_extension(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
7+
def truncate_rule_group_name(name, max_length=260):
8+
return name[:max_length]

0 commit comments

Comments
 (0)