Skip to content

Commit a47d1ab

Browse files
authored
[AKS] az aks update: Add --enable-http-proxy option (#8826)
1 parent 3e80e22 commit a47d1ab

File tree

10 files changed

+1300
-490
lines changed

10 files changed

+1300
-490
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
1212
Pending
1313
+++++++
1414

15+
18.0.0b13
16+
+++++++
17+
* Add option `--enable-http-proxy` to `az aks update`.
18+
1519
18.0.0b12
1620
+++++++
1721
* Add option `--acns-transit-encryption-type <None|WireGuard>` to `az aks create/update`

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,9 @@
12651265
- name: --disable-http-proxy
12661266
type: bool
12671267
short-summary: Disable HTTP Proxy Configuration on the cluster.
1268+
- name: --enable-http-proxy
1269+
type: bool
1270+
short-summary: Enable HTTP Proxy Configuration on the cluster.
12681271
examples:
12691272
- name: Reconcile the cluster back to its current state.
12701273
text: az aks update -g MyResourceGroup -n MyManagedCluster

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@ def load_arguments(self, _):
14741474

14751475
c.argument('migrate_vmas_to_vms', is_preview=True, action='store_true')
14761476
c.argument("disable_http_proxy", action="store_true", is_preview=True)
1477+
c.argument("enable_http_proxy", action="store_true", is_preview=True)
14771478

14781479
with self.argument_context("aks upgrade") as c:
14791480
c.argument("kubernetes_version", completer=get_k8s_upgrades_completion_list)

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ def aks_update(
837837
azure_keyvault_kms_key_vault_resource_id=None,
838838
http_proxy_config=None,
839839
disable_http_proxy=False,
840+
enable_http_proxy=False,
840841
bootstrap_artifact_source=None,
841842
bootstrap_container_registry_resource_id=None,
842843
# addons

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,16 @@ def get_disable_http_proxy(self) -> bool:
28632863

28642864
return disable_http_proxy
28652865

2866+
def get_enable_http_proxy(self) -> bool:
2867+
"""Obtain the value of enable_http_proxy.
2868+
2869+
:return: bool
2870+
"""
2871+
# read the original value passed by the command
2872+
enable_http_proxy = self.raw_param.get("enable_http_proxy")
2873+
2874+
return enable_http_proxy
2875+
28662876

28672877
# pylint: disable=too-many-public-methods
28682878
class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
@@ -5350,6 +5360,13 @@ def update_http_proxy_enabled(self, mc: ManagedCluster) -> ManagedCluster:
53505360
)
53515361
mc.http_proxy_config.enabled = False
53525362

5363+
if self.context.get_enable_http_proxy():
5364+
if mc.http_proxy_config is None:
5365+
mc.http_proxy_config = (
5366+
self.models.ManagedClusterHTTPProxyConfig() # pylint: disable=no-member
5367+
)
5368+
mc.http_proxy_config.enabled = True
5369+
53535370
return mc
53545371

53555372
def update_mc_profile_preview(self) -> ManagedCluster:

src/aks-preview/azext_aks_preview/tests/latest/recordings/test_aks_create_and_update_with_http_proxy_config.yaml

Lines changed: 1220 additions & 489 deletions
Large diffs are not rendered by default.

src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6143,6 +6143,22 @@ def test_aks_create_and_update_with_http_proxy_config(
61436143
],
61446144
)
61456145

6146+
self.kwargs.update(
6147+
{
6148+
"resource_group": resource_group,
6149+
"name": aks_name,
6150+
}
6151+
)
6152+
6153+
reenable_cmd = "aks update --resource-group={resource_group} --name={name} --enable-http-proxy"
6154+
6155+
self.cmd(
6156+
reenable_cmd,
6157+
checks=[
6158+
self.check("httpProxyConfig.enabled", True),
6159+
],
6160+
)
6161+
61466162
# delete
61476163
self.cmd(
61486164
"aks delete -g {resource_group} -n {name} --yes --no-wait",

src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6502,6 +6502,40 @@ def test_update_http_proxy_config(self):
65026502
)
65036503
self.assertEqual(dec_mc_2, ground_truth_mc_2)
65046504

6505+
# custom value
6506+
dec_3 = AKSPreviewManagedClusterUpdateDecorator(
6507+
self.cmd,
6508+
self.client,
6509+
{
6510+
"enable_http_proxy": True,
6511+
},
6512+
CUSTOM_MGMT_AKS_PREVIEW,
6513+
)
6514+
6515+
mc_3 = self.models.ManagedCluster(
6516+
location="test_location",
6517+
http_proxy_config = self.models.ManagedClusterHTTPProxyConfig(
6518+
enabled=False,
6519+
httpProxy="http://cli-proxy-vm:3128/",
6520+
httpsProxy="https://cli-proxy-vm:3129/",
6521+
)
6522+
)
6523+
dec_3.context.attach_mc(mc_3)
6524+
# fail on passing the wrong mc object
6525+
with self.assertRaises(CLIInternalError):
6526+
dec_3.update_http_proxy_enabled(None)
6527+
dec_mc_3 = dec_3.update_http_proxy_enabled(mc_3)
6528+
6529+
ground_truth_mc_3 = self.models.ManagedCluster(
6530+
location="test_location",
6531+
http_proxy_config = self.models.ManagedClusterHTTPProxyConfig(
6532+
enabled=True,
6533+
httpProxy="http://cli-proxy-vm:3128/",
6534+
httpsProxy="https://cli-proxy-vm:3129/",
6535+
)
6536+
)
6537+
self.assertEqual(dec_mc_3, ground_truth_mc_3)
6538+
65056539
def test_update_pod_identity_profile(self):
65066540
# default value in `aks_update`
65076541
dec_1 = AKSPreviewManagedClusterUpdateDecorator(

src/aks-preview/linter_exclusions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ aks update:
245245
disable_http_proxy:
246246
rule_exclusions:
247247
- option_length_too_long
248+
enable_http_proxy:
249+
rule_exclusions:
250+
- option_length_too_long
248251
aks delete:
249252
parameters:
250253
ignore_pod_disruption_budget:

src/aks-preview/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from setuptools import setup, find_packages
1111

12-
VERSION = "18.0.0b12"
12+
VERSION = "18.0.0b13"
1313

1414
CLASSIFIERS = [
1515
"Development Status :: 4 - Beta",

0 commit comments

Comments
 (0)