|
41 | 41 | CONST_PRIVATE_DNS_ZONE_CONTRIBUTOR_ROLE, |
42 | 42 | CONST_DNS_ZONE_CONTRIBUTOR_ROLE, |
43 | 43 | CONST_ARTIFACT_SOURCE_CACHE, |
| 44 | + CONST_NONE_UPGRADE_CHANNEL, |
44 | 45 | ) |
45 | 46 | from azure.cli.command_modules.acs._helpers import ( |
46 | 47 | check_is_managed_aad_cluster, |
@@ -8482,6 +8483,38 @@ def update_mc_profile_default(self) -> ManagedCluster: |
8482 | 8483 | mc = self.update_node_resource_group_profile(mc) |
8483 | 8484 | # update bootstrap profile |
8484 | 8485 | 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 | + |
8485 | 8518 | return mc |
8486 | 8519 |
|
8487 | 8520 | def check_is_postprocessing_required(self, mc: ManagedCluster) -> bool: |
|
0 commit comments