Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

`az aks update --attach-acr`: 'NoneType' object has no attribute 'replace' #29845

Open temp-exp123 opened 2 months ago

temp-exp123 commented 2 months ago

Describe the bug

Running:

az aks update --resource-group my-rg --name rg-hash --attach-acr "sub/path"

Results in an error even with correct owner subscription roles.

Related command

az aks update --resource-group my-rg --name rg-hash --attach-acr "sub/path"

Errors

The behavior of this command has been altered by the following extension: aks-preview
'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[###                                 ]  10.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[#######                             ]  20.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[##########                          ]  30.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[##############                      ]  40.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[##################                  ]  50.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[#####################               ]  60.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[#########################           ]  70.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[############################        ]  80.0000%'NoneType' object has no attribute 'replace'
Waiting for AAD role to propagate[################################    ]  90.0000%'NoneType' object has no attribute 'replace'
Could not create a role assignment for ACR. Are you an Owner on this subscription?

image

Issue script & Debug output

Cannot do this, too much sensitive information but the part that matters is:

cli.azure.cli.command_modules.acs._roleassignments: 'NoneType' object has no attribute 'replace'

and

cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/home/erhkim/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 890, in aks_update
    mc = aks_update_decorator.update_mc_profile_preview()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/erhkim/.azure/cliextensions/aks-preview/azext_aks_preview/managed_cluster_decorator.py", line 5390, in update_mc_profile_preview
    mc = self.update_mc_profile_default()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/managed_cluster_decorator.py", line 8449, in update_mc_profile_default
    self.process_attach_detach_acr(mc)
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/managed_cluster_decorator.py", line 7219, in process_attach_detach_acr
    self.context.external_functions.ensure_aks_acr(
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/_roleassignments.py", line 334, in ensure_aks_acr
    ensure_aks_acr_role_assignment(cmd, assignee, registry.id, detach, is_service_principal)
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/_roleassignments.py", line 318, in ensure_aks_acr_role_assignment
    raise AzCLIError("Could not create a role assignment for ACR. Are you an Owner on this subscription?")

Expected behavior

I expect the command to be "Running" and a successful attachment of the ACR

Environment Summary

azure-cli 2.64.0

core 2.64.0 telemetry 1.1.0

Extensions: aks-preview 8.0.0b1 interactive 0.5.3

Dependencies: msal 1.30.0 azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3' Extensions directory '/home/user/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Aug 28 2024, 05:45:49) [GCC 13.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 2 months ago

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

temp-exp123 commented 2 months ago

Worked on a lower version 2.42 and 2.62 but not on 2.64 or 2.63

arenk commented 3 weeks ago

Having the same issue when creating an Azure Container Storage with Elastic SAN with az aks update -n xxx -g xxx --enable-azure-container-storage elasticSan

azure-cli 2.65.0

FumingZhang commented 2 weeks ago

@mukhoakash could you please help take a look?

mukhoakash commented 2 weeks ago

Fix has been merged awaiting release in commit