-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
Auto-ResolveAuto resolve by botAuto resolve by botContainer Registryaz acraz acrService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.
Description
Describe the bug
az acr check_health throws when registry is not found
In acr/check_health.py, in _check_registry_health, get_registry_by_name may return None for
the registry. But not all references to the registry check for this
first, resulting in exception when it checks whether ABAC is enabled.
This PR checks whether the registry is non-None before it checks
registry.role_assignment_mode for ABAC repository permissions.
Related command
07:38 $ sudo az acr check-health -n codeexecservice --yes
Errors
Docker daemon status: available
Docker version: 'Docker version 28.3.0, build 265f709, platform linux/amd64'
Docker pull of 'mcr.microsoft.com/mcr/hello-world:latest' : OK
Azure CLI version: 2.74.0
DNS lookup to codeexecservice.azurecr.io at IP 40.64.135.170 : OK
The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute 'role_assignment_mode'
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/acr/check_health.py", line 464, in acr_check_health
_check_registry_health(cmd, registry_name, repository, ignore_errors)
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/acr/check_health.py", line 348, in _check_registry_health
registry_abac_enabled = registry.role_assignment_mode == RoleAssignmentMode.ABAC_REPOSITORY_PERMISSIONS
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'role_assignment_mode'
Issue script & Debug output
provided above
Expected behavior
No crash. Here is the output after I added a None check on the failing line of code, and installed helm and notary, which are apparently required to run check_health:
08:03 $ sudo az acr check-health -n codeexecservice --yes
Docker daemon status: available
Docker version: 'Docker version 28.3.0, build 265f709, platform linux/amd64'
Docker pull of 'mcr.microsoft.com/mcr/hello-world:latest' : OK
Azure CLI version: 2.74.0
DNS lookup to codeexecservice.azurecr.io at IP 40.64.135.170 : OK
Challenge endpoint https://codeexecservice.azurecr.io/v2/ : OK
Fetch refresh token for registry 'codeexecservice.azurecr.io' : OK
Fetch access token for registry 'codeexecservice.azurecr.io' : OK
Helm version: 3.18.3
Notary version: notary
Version:
Git commit:
Go version: go1.18.1
Please refer to https://aka.ms/acr/health-check for more information.
Environment Summary
azure-cli 2.74.0 *
core 2.74.0 *
telemetry 1.1.0
Extensions:
azure-devops 1.0.2
Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0
Python location '/opt/az/bin/python3'
Config directory '/home/nathan/.azure'
Extensions directory '/home/nathan/.azure/cliextensions'
Python (Linux) 3.12.10 (main, May 27 2025, 09:12:38) [GCC 11.4.0]
Additional context
I work at MS, alias nathansa, if you need to contact me internally.
Metadata
Metadata
Assignees
Labels
Auto-ResolveAuto resolve by botAuto resolve by botContainer Registryaz acraz acrService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.