check kubernetes version only when the version changed (#54090)

* check kubernetes version only when the version changed

* fix typo
This commit is contained in:
Yuwei Zhou 2019-03-22 10:23:11 +08:00 committed by ansibot
parent 2d15811843
commit fcc3353216

View file

@ -539,11 +539,11 @@ class AzureRMManagedCluster(AzureRMModuleBase):
if agentpoolcount > 1: if agentpoolcount > 1:
self.fail('You cannot specify more than one agent_pool_profiles currently') 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: if not response:
to_be_updated = True 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: else:
self.results = response self.results = response
self.results['changed'] = False self.results['changed'] = False
@ -582,7 +582,7 @@ class AzureRMManagedCluster(AzureRMModuleBase):
to_be_updated = True to_be_updated = True
if response['kubernetes_version'] != self.kubernetes_version: 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: 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)) self.fail('Cannot upgrade kubernetes version to {0}, supported value are {1}'.format(self.kubernetes_version, upgrade_versions))
to_be_updated = True to_be_updated = True