Skip to content

Commit cc6d0bd

Browse files
authored
{AKS} Fix the location logic for managed namespace update (#9723)
1 parent f3ce3d7 commit cc6d0bd

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
15+
19.0.0b28
16+
+++++++
1417
* Fix `match_condition` kwarg leaking to HTTP transport by overriding `put_mc` and `add_agentpool` to pass `if_match` / `if_none_match` directly to the vendored SDK. This change fixes the compatibility issue as azure-cli/acs module adopts TypeSpec emitted SDKs while azure-cli-extensions/aks-preview still uses the autorest emitted SDK.
1518
+ `az aks list-vm-skus`: New command to list available VM SKUs for AKS clusters in a given region.
1619
* `az aks create/update`: Add `--enable-service-account-image-pull`, `--disable-service-account-image-pull`, and `--service-account-image-pull-default-managed-identity-id` parameters to manage service account based image pull settings.
1720
* `az aks list-vm-skus`: New command to list available VM SKUs for AKS clusters in a given region.
1821
* Add managed GPU enablement option to node pool property in `az aks nodepool add` and `az aks nodepool update`.
22+
* `az aks namespace update`: Fix location should use existing namespace location.
1923

2024
19.0.0b27
2125
+++++++

src/aks-preview/azext_aks_preview/managednamespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def aks_managed_namespace_update(cmd, client, raw_parameters, headers, existedNa
201201
namespace_name = raw_parameters.get("name")
202202

203203
namespace_config = updateNamespace(cmd, raw_parameters, existedNamespace)
204-
namespace_config.location = get_cluster_location(cmd, resource_group_name, cluster_name)
204+
namespace_config.location = existedNamespace.location
205205

206206
return sdk_no_wait(
207207
no_wait,

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,52 @@ def test_update_managed_namespace_with_invalid_delete_policy(self, mock_get_clie
287287
ns.aks_managed_namespace_update(cmd, None, raw_parameters, None, None, False)
288288
self.assertIn(err, str(cm.exception))
289289

290+
def test_update_managed_namespace_sets_location_from_existing_namespace(self, mock_get_client):
291+
register_aks_preview_resource_type()
292+
cli_ctx = MockCLI()
293+
cmd = MockCmd(cli_ctx)
294+
295+
mock_client = Mock()
296+
297+
existing_ns = Mock()
298+
existing_ns.name = "test_managed_namespace"
299+
existing_ns.location = "westus2"
300+
existing_ns.properties.default_resource_quota.cpu_request = "300m"
301+
existing_ns.properties.default_resource_quota.cpu_limit = "500m"
302+
existing_ns.properties.default_resource_quota.memory_request = "1Gi"
303+
existing_ns.properties.default_resource_quota.memory_limit = "2Gi"
304+
existing_ns.properties.default_network_policy.ingress = "DenyAll"
305+
existing_ns.properties.default_network_policy.egress = "AllowAll"
306+
existing_ns.properties.adoption_policy = "Never"
307+
existing_ns.properties.delete_policy = "Keep"
308+
309+
raw_parameters = {
310+
"resource_group_name": "test_rg",
311+
"cluster_name": "test_cluster",
312+
"name": "test_managed_namespace",
313+
"tags": {},
314+
"labels": None,
315+
"annotations": ["a=c"],
316+
"cpu_request": None,
317+
"cpu_limit": None,
318+
"memory_request": None,
319+
"memory_limit": None,
320+
"ingress_policy": None,
321+
"egress_policy": None,
322+
"adoption_policy": None,
323+
"delete_policy": None,
324+
}
325+
326+
ns.aks_managed_namespace_update(cmd, mock_client, raw_parameters, None, existing_ns, False)
327+
328+
# The namespace passed to begin_create_or_update should carry the existing location
329+
call_args = mock_client.begin_create_or_update.call_args
330+
namespace_config = call_args[0][3] # 4th positional arg
331+
self.assertEqual(namespace_config.location, "westus2")
332+
333+
# No managed cluster GET should be needed for the update path
334+
mock_get_client.assert_not_called()
335+
290336

291337
if __name__ == "__main__":
292338
unittest.main()

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 find_packages, setup
1111

12-
VERSION = "19.0.0b27"
12+
VERSION = "19.0.0b28"
1313

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

0 commit comments

Comments
 (0)