Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.99k forks source link

AttributeError: 'ManagedCluster' object has no attribute 'done' #27940

Closed acsyanqinglu closed 7 months ago

acsyanqinglu commented 11 months ago

Describe the bug

When I update the app routing add-on to enable the Azure Key Vault secret store CSI driver and apply the role assignment, I got the following error: Could not find service principal or user assigned MSI for roleassignment The command failed with an unexpected error. Here is the traceback: 'ManagedCluster' object has no attribute 'done'

Related command

[ ~ ]$ az aks approuting update -g xxxxxxxx -n xxxxxxxx --enable-kv --attach-kv ${KEYVAULTID} Could not find service principal or user assigned MSI for roleassignment The command failed with an unexpected error. Here is the traceback: 'ManagedCluster' object has no attribute 'done' Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(*args, kwargs) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2718, in aks_approuting_update return _aks_approuting_update( File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2840, in _aks_approuting_update return _keyvault_update(poller, cmd, keyvault_id=keyvault_id) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2855, in _keyvault_update while not poller.done(): AttributeError: 'ManagedCluster' object has no attribute 'done' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Errors

Could not find service principal or user assigned MSI for roleassignment The command failed with an unexpected error. Here is the traceback: 'ManagedCluster' object has no attribute 'done'

Issue script & Debug output

cli.azure.cli.command_modules.acs.addonconfiguration: Could not find service principal or user assigned MSI for roleassignment cli.azure.cli.command_modules.acs.base_decorator: The intermediate 'enable_azure_container_storage' does not exist. Return default value 'None'. cli.azure.cli.command_modules.acs.base_decorator: The intermediate 'disable_azure_container_storage' does not exist. Return default value 'None'. cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(*args, kwargs) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2718, in aks_approuting_update return _aks_approuting_update( File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2840, in _aks_approuting_update return _keyvault_update(poller, cmd, keyvault_id=keyvault_id) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2855, in _keyvault_update while not poller.done(): AttributeError: 'ManagedCluster' object has no attribute 'done'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback: az_command_data_logger: The command failed with an unexpected error. Here is the traceback: cli.azure.cli.core.azclierror: 'ManagedCluster' object has no attribute 'done' Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2718, in aks_approuting_update return _aks_approuting_update( File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2840, in _aks_approuting_update return _keyvault_update(poller, cmd, keyvault_id=keyvault_id) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2855, in _keyvault_update while not poller.done(): AttributeError: 'ManagedCluster' object has no attribute 'done' az_command_data_logger: 'ManagedCluster' object has no attribute 'done' Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2718, in aks_approuting_update return _aks_approuting_update( File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2840, in _aks_approuting_update return _keyvault_update(poller, cmd, keyvault_id=keyvault_id) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2855, in _keyvault_update while not poller.done(): AttributeError: 'ManagedCluster' object has no attribute 'done' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fc9842695e0>]

Expected behavior

What can I do to get the update successful?

Environment Summary

azure-cli 2.54.0

core 2.54.0 telemetry 1.1.0

Extensions: ai-examples 0.2.5 aks-preview 0.5.171 ml 2.21.1 ssh 2.0.2

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

Python location '/usr/bin/python3.9' Extensions directory '/home/yanqing/.azure/cliextensions' Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.14 (main, Oct 12 2023, 19:48:32) [GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 11 months ago

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

clarenceb commented 11 months ago

I am having this exact same issue, using AKS 1.27.7.

paolosalvatori commented 10 months ago

I still experience the same issue. These are my Azure CLI and extensions versions. Please note that my user has Key Vault Administrator role on the Azure Key Vault used by the command:

{
  "azure-cli": "2.55.0",
  "azure-cli-core": "2.55.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "aks-preview": "0.5.173",
    "alb": "1.0.0",
    "amg": "1.2.9",
    "bastion": "0.3.0",
    "connectedk8s": "1.6.0",
    "containerapp": "0.3.46",
    "costmanagement": "0.2.1",
    "fleet": "1.0.2",
    "k8s-configuration": "1.7.0",
    "k8s-extension": "1.5.3",
    "ssh": "2.0.2",
    "vm-repair": "0.5.9"
  }
}
jovieir commented 10 months ago

@paolosalvatori @acsyanqinglu could you kindly share full repro steps for this? I've been unable to reproduce the behavior so far on cli 2.55 and aks-preview 0.5.171 / 0.5.173.

acsyanqinglu commented 10 months ago

@jovieir the repro steps are to go to the kubernetes account Bash window and execute the following:

KEYVAULTID=$(az keyvault show --name TheKeyVaultName --query "id" --output tsv) az aks approuting update -g TheResourceGroupName -n TheNameSpaceName --enable-kv --attach-kv ${KEYVAULTID}

jovieir commented 10 months ago

@acsyanqinglu I'm afraid I'm unable to repro with a new cluster. Steps:

  1. az aks create -g -n -l westeurope
  2. az aks approuting enable -g -n
  3. KEYVAULTID=$(az keyvault show --name --query "id" --output tsv)
  4. az aks approuting update -g -n --enable-kv --attach-kv ${KEYVAULTID} --verbose --debug

az version { "azure-cli": "2.55.0", "azure-cli-core": "2.55.0", "azure-cli-telemetry": "1.1.0", "extensions": { "aks-preview": "0.5.171", "azure-firewall": "1.0.0", "k8s-configuration": "1.7.0", "k8s-extension": "1.4.5", "vmware": "6.0.0" } }

az aks approuting update -g aksapp -n aks --enable-kv --attach-kv ${KEYVAULTID} --debug --verbose cli.knack.cli: Command arguments: ['aks', 'approuting', 'update', '-g', 'aksapp', '-n', 'aks', '--enable-kv', '--attach-kv', '/subscriptions//resourceGroups/aksapp/providers/Microsoft.KeyVault/vaults/', '--debug', '--verbose'] [...] cli.knack.cli: Event: Cli.SuccessfulExecute [] cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f71cf1b0ea0>] az_command_data_logger: exit code: 0 cli.main: Command ran in 131.307 seconds (init: 0.211, invoke: 131.096)

Does this also repro on Cloud Shell?

acsyanqinglu commented 10 months ago

@jovieir I just tried and still get the same error. Here is the result with some values masked:

yanqing [ ~ ]$ az version { "azure-cli": "2.55.0", "azure-cli-core": "2.55.0", "azure-cli-telemetry": "1.1.0", "extensions": { "ai-examples": "0.2.5", "aks-preview": "0.5.171", "ml": "2.22.0", "ssh": "2.0.2" } } yanqing [ ~ ]$ KEYVAULTID=$(az keyvault show --name xxxxxx --query "id" --output tsv) yanqing [ ~ ]$ az aks approuting update -g xxxxxx -n xxxxxx --enable-kv --attach-kv ${KEYVAULTID} Could not find service principal or user assigned MSI for roleassignment The command failed with an unexpected error. Here is the traceback: 'ManagedCluster' object has no attribute 'done' Traceback (most recent call last): File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(*args, kwargs) File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2718, in aks_approuting_update return _aks_approuting_update( File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2840, in _aks_approuting_update return _keyvault_update(poller, cmd, keyvault_id=keyvault_id) File "/home/yanqing/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 2855, in _keyvault_update while not poller.done(): AttributeError: 'ManagedCluster' object has no attribute 'done' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

jovieir commented 10 months ago

@acsyanqinglu think I got it, looks like there's a precondition of omsagent/monitoring being installed for this to repro.

az aks enable-addons -g -n --addons monitoring az aks approuting update -g -n --enable-kv --attach-kv

This repro'd the "AttributeError: 'ManagedCluster' object has no attribute 'done'" error.

I'm looking into this. As a workaround for the time being, the below should mitigate:

acsyanqinglu commented 10 months ago

@jovieir The workaround works. Thanks!

paolosalvatori commented 10 months ago

Thanks for the workaround @jovieir. Did you implement a fix for the issue? Thanks

jovieir commented 10 months ago

I'm afraid I haven't had the time to fix/PR, but I'm not from the CLI team. @yonzhan is there anyone from the CLI team that can take a look at this?

FumingZhang commented 9 months ago

+ feature owner @bosesuneha to help fix the issue

bosesuneha commented 9 months ago

Looking into it.

FumingZhang commented 7 months ago

Issue has been fixed in aks-preview 1.0.0b4.