diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index be9d2d190af..d9b98ef628f 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -12,6 +12,7 @@ To release a new version, please select a new version number (usually plus 1 to Pending +++++++ +* Fix `az aks update` command failing on updating the ssh key value if cluster was created without ssh key, see issue `\#5559 `_. * Mark "--enable-pod-security-policy" deprecated 0.5.115 @@ -28,7 +29,7 @@ Pending +++++++ * Fix workload identity update error after oidc issure GA in azure-cli. -* Fix `az aks update` command failing on SP-based cluster blocked by validation in AzureMonitorMetrics Addon, see issue `\#5336 `_. +* Fix `az aks update` command failing on SP-based cluster blocked by validation in AzureMonitorMetrics Addon, see issue `\#5488 `_. * Fix `az aks update` command failing on changes not related to outbound type conversion, see issue `\#24430 https://github.com/Azure/azure-cli/issues/24430>`_. 0.5.112 diff --git a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py index b3a126b3c74..1eb2f83004c 100644 --- a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py @@ -3176,6 +3176,8 @@ def update_linux_profile(self, mc: ManagedCluster) -> ManagedCluster: ssh_key_value = self.context.get_ssh_key_value_for_update() if ssh_key_value: + if mc.linux_profile is None: + raise InvalidArgumentValueError("Updating the cluster with no ssh key set at creation is not supported") mc.linux_profile.ssh = self.models.ContainerServiceSshConfiguration( public_keys=[ self.models.ContainerServiceSshPublicKey( @@ -3183,7 +3185,6 @@ def update_linux_profile(self, mc: ManagedCluster) -> ManagedCluster: ) ] ) - return mc def update_mc_profile_preview(self) -> ManagedCluster: diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py index 152a1b59684..b3e4f17b4e0 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py @@ -5804,6 +5804,21 @@ def test_update_azure_monitor_profile(self): ) self.assertEqual(dec_mc_1, ground_truth_mc_1) + def test_update_linux_profile(self): + dec_1 = AKSPreviewManagedClusterUpdateDecorator( + self.cmd, + self.client, + {"ssh_key_value": "test_key"}, + CUSTOM_MGMT_AKS_PREVIEW, + ) + mc_1 = self.models.ManagedCluster( + location="test_location", + ) + dec_1.context.attach_mc(mc_1) + # fail on cluster has no linux profile + with self.assertRaises(InvalidArgumentValueError): + dec_mc_1 = dec_1.update_linux_profile(mc_1) + def test_update_mc_profile_preview(self): import inspect