Skip to content

Commit 68ef754

Browse files
authored
[AKS] az aks update: Make specified version to match current version when turning off autoupgrade (#31018)
1 parent 14be75f commit 68ef754

File tree

4 files changed

+1209
-529
lines changed

4 files changed

+1209
-529
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
CONST_PRIVATE_DNS_ZONE_CONTRIBUTOR_ROLE,
4242
CONST_DNS_ZONE_CONTRIBUTOR_ROLE,
4343
CONST_ARTIFACT_SOURCE_CACHE,
44+
CONST_NONE_UPGRADE_CHANNEL,
4445
)
4546
from azure.cli.command_modules.acs._helpers import (
4647
check_is_managed_aad_cluster,
@@ -8482,6 +8483,38 @@ def update_mc_profile_default(self) -> ManagedCluster:
84828483
mc = self.update_node_resource_group_profile(mc)
84838484
# update bootstrap profile
84848485
mc = self.update_bootstrap_profile(mc)
8486+
# update kubernetes version and orchestrator version
8487+
mc = self.update_kubernetes_version_and_orchestrator_version(mc)
8488+
return mc
8489+
8490+
def update_kubernetes_version_and_orchestrator_version(self, mc: ManagedCluster) -> ManagedCluster:
8491+
"""Update kubernetes version and orchestrator version for the ManagedCluster object.
8492+
8493+
:param mc: The ManagedCluster object to be updated.
8494+
:return: The updated ManagedCluster object.
8495+
"""
8496+
self._ensure_mc(mc)
8497+
8498+
# Check if auto_upgrade_channel is set to "none"
8499+
auto_upgrade_channel = self.context.get_auto_upgrade_channel()
8500+
if auto_upgrade_channel == CONST_NONE_UPGRADE_CHANNEL:
8501+
warning_message = (
8502+
"Since auto-upgrade-channel is set to none, cluster kubernetesVersion will be set to the value of "
8503+
"currentKubernetesVersion, all agent pools orchestratorVersion will be set to the value of "
8504+
"currentOrchestratorVersion respectively. Continue?"
8505+
)
8506+
if not self.context.get_yes() and not prompt_y_n(warning_message, default="n"):
8507+
raise DecoratorEarlyExitException()
8508+
8509+
# Set kubernetes version to match the current kubernetes version if it has a value
8510+
if mc.current_kubernetes_version:
8511+
mc.kubernetes_version = mc.current_kubernetes_version
8512+
8513+
# Set orchestrator version for each agent pool to match the current orchestrator version if it has a value
8514+
for agent_pool in mc.agent_pool_profiles:
8515+
if agent_pool.current_orchestrator_version:
8516+
agent_pool.orchestrator_version = agent_pool.current_orchestrator_version
8517+
84858518
return mc
84868519

84878520
def check_is_postprocessing_required(self, mc: ManagedCluster) -> bool:

0 commit comments

Comments
 (0)