From fcc33532166eed80d634b30cbc957c1bd76317dc Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Fri, 22 Mar 2019 10:23:11 +0800 Subject: [PATCH] check kubernetes version only when the version changed (#54090) * check kubernetes version only when the version changed * fix typo --- lib/ansible/modules/cloud/azure/azure_rm_aks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_aks.py b/lib/ansible/modules/cloud/azure/azure_rm_aks.py index 0bed80a0751..6984d8659ab 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_aks.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_aks.py @@ -539,11 +539,11 @@ class AzureRMManagedCluster(AzureRMModuleBase): if agentpoolcount > 1: self.fail('You cannot specify more than one agent_pool_profiles currently') - available_versions = self.get_all_versions() - if self.kubernetes_version not in available_versions.keys(): - self.fail("Unsupported kubernetes version. Excepted one of {0} but get {1}".format(available_versions.keys(), self.kubernetes_version)) if not response: to_be_updated = True + available_versions = self.get_all_versions() + if self.kubernetes_version not in available_versions.keys(): + self.fail("Unsupported kubernetes version. Expected one of {0} but got {1}".format(available_versions.keys(), self.kubernetes_version)) else: self.results = response self.results['changed'] = False @@ -582,7 +582,7 @@ class AzureRMManagedCluster(AzureRMModuleBase): to_be_updated = True if response['kubernetes_version'] != self.kubernetes_version: - upgrade_versions = available_versions.get(response['kubernetes_version']) + upgrade_versions = available_versions.get(response['kubernetes_version']) or available_versions.keys() if upgrade_versions and self.kubernetes_version not in upgrade_versions: self.fail('Cannot upgrade kubernetes version to {0}, supported value are {1}'.format(self.kubernetes_version, upgrade_versions)) to_be_updated = True