Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

ManagedCluster' object has no attribute 'upgrade_settings' #27525

Open ionutleca opened 1 year ago

ionutleca commented 1 year ago

Describe the bug

az aks update --name ** --resource-group ** --api-server-authorized-ip-ranges ** fails with az cli 2.53.0:

...
if mc.upgrade_settings is not None and mc.upgrade_settings.override_settings is not None and mc.upgrade_settings.override_settings.until is not None:
AttributeError: 'ManagedCluster' object has no attribute 'upgrade_settings'

Related command

az aks update --name --resource-group --api-server-authorized-ip-ranges **

Errors

ERROR: 'ManagedCluster' object has no attribute 'upgrade_settings'

Issue script & Debug output

WARNING: The behavior of this command has been altered by the following extension: aks-preview ERROR: The command failed with an unexpected error. Here is the traceback: ERROR: 'ManagedCluster' object has no attribute 'upgrade_settings' Traceback (most recent call last): File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(*args, kwargs) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/opt/az/azcliextensions/aks-preview/azext_aks_preview/custom.py", line 832, in aks_update mc = aks_update_decorator.update_mc_profile_preview() File "/opt/az/azcliextensions/aks-preview/azext_aks_preview/managed_cluster_decorator.py", line 3198, in update_mc_profile_preview mc = self.update_mc_profile_default() File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/acs/managed_cluster_decorator.py", line 7336, in update_mc_profile_default mc = self.update_upgrade_settings(mc) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/acs/managed_cluster_decorator.py", line 6458, in update_upgrade_settings if mc.upgrade_settings is not None and mc.upgrade_settings.override_settings is not None and mc.upgrade_settings.override_settings.until is not None: AttributeError: 'ManagedCluster' object has no attribute 'upgrade_settings'

Expected behavior

No error, it was working in az cli 2.52.0.

Environment Summary

azure-cli 2.53.0

core 2.53.0 telemetry 1.1.0

Extensions: azure-devops 0.26.0

Dependencies: msal 1.24.0b2 azure-mgmt-resource 23.1.0b2

Additional context

No response

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

andyliuliming commented 1 year ago

+@fumingzhang @wenjungaogaogao to take a look

wenjungaogaogao commented 1 year ago

Hello @ionutleca, could you check your aks-preview extension version? The issue might happen if you are using latest azure-cli with aks-preview version prior 0.5.134.

$ az version { "azure-cli": "2.53.0", "azure-cli-core": "2.53.0", "azure-cli-telemetry": "1.1.0", "extensions": { "aks-preview": "0.5.161", "fleet": "0.2.2" } }

Please try update the extension version and let us know if the issue is still there. Thanks!

ionutleca commented 1 year ago

Hi, @wenjungaogaogao, I tested with "aks-preview": "0.5.161" and it does seem to work.

Thank you!

mmrazik commented 1 year ago

@wenjungaogaogao I actually somewhat disagree with this being closed. az-cli should be made more robust and handle version inconsistencies in a more robust way (instead of "crashing" like in this case it should tell the customer what is going on).

mmrazik commented 1 year ago

And apparently this was not the first occurrence of such problem https://medium.com/@maciej.skorupka/azure-and-a-problem-with-az-cli-with-aks-preview-extension-583bc5ac55d4

ionutleca commented 1 year ago

@mmrazik, I am the one that closed this because I found the fix for it. But I agree that it's not an ideal behaviour, version incompatibility between the core cli and it's extensions shouldn't be detected by users trying things out. I'll reopen this and let the azure-cli team handle it.