Azure / azure-cli

Azure Command-Line Interface
MIT License
4k stars 2.98k forks source link

AZ CLI 2.65.0 upgrade via homebrew to version 2.65.0_1 caused multiplicity of errors #30148

Open jaromirmikulik opened 1 day ago

jaromirmikulik commented 1 day ago

Describe the bug

AZ CLI version 2.65.0 stop working after upgrade on MacOS via homebrew to homebrew version 2.65.0_1. If homebrew version 2.65.0 is used, it works correctly, but upgrade to 2.65.0_1 brokes dependancies.

Related command

az aks list -otable

az network bastion ssh --ids /subscriptions/abc123/resourceGroups/NETWORK-RG/providers/Microsoft.Network/bastionHosts/BASTION --target-resource-id /subscriptions/abc123/resourceGroups/VM-RG/providers/Microsoft.Compute/virtualMachines/mylab --username my_user_name --auth-type password

Errors

myuser@ntb1234 ~ $ az aks list -otable
The command failed with an unexpected error. Here is the traceback:
'NoneType' object has no attribute '__dict__'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 564, in execute
    self.commands_loader.load_arguments(command)
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/__init__.py", line 527, in load_arguments
    loader.load_arguments(command)  # this adds entries to the argument registries
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/uuser/.azure/cliextensions/aks-preview/azext_aks_preview/__init__.py", line 45, in load_arguments
    load_arguments(self, command)
  File "/Users/uuser/.azure/cliextensions/aks-preview/azext_aks_preview/_params.py", line 433, in load_arguments
    k8s_support_plans = self.get_models(
                        ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/__init__.py", line 782, in get_models
    return get_sdk(self.cli_ctx, resource_type, *attr_args, mod='models', operation_group=operation_group)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/profiles/__init__.py", line 91, in get_sdk
    return _sdk_get_versioned_sdk(cli_ctx.cloud.profile, resource_type, *attr_args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 694, in get_versioned_sdk
    sdk_path = get_versioned_sdk_path(api_profile, resource_type, operation_group)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 686, in get_versioned_sdk_path
    api_version = getattr(api_version, operation_group)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 481, in __getattr__
    self._resolve()
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 468, in _resolve
    for operation_group_name, operation_type in self._client_type.__dict__.items():
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '__dict__'. Did you mean: '__dir__'?
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
myuser@ntb1234 ~ $
myuser@ntb1234 ~ $ az network bastion ssh --ids /subscriptions/abc123/resourceGroups/NETWORK-RG/providers/Microsoft.Network/bastionHosts/BASTION --target-resource-id /subscriptions/abc123/resourceGroups/VM-RG/providers/Microsoft.Compute/virtualMachines/mylab --username my_user_name --auth-type password
The command failed with an unexpected error. Here is the traceback:
No module named 'pkg_resources'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/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/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/uuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 145, in ssh_bastion_host
    _test_extension(SSH_EXTENSION_NAME)
  File "/Users/uuser/.azure/cliextensions/bastion/azext_bastion/custom.py", line 78, in _test_extension
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
myuser@ntb1234 ~ $

Issue script & Debug output

.

Expected behavior

az aks list -otable should list AKS clusters in subscription

az network bastion ssh --ids /subscriptions/abc123/resourceGroups/NETWORK-RG/providers/Microsoft.Network/bastionHosts/BASTION --target-resource-id /subscriptions/abc123/resourceGroups/VM-RG/providers/Microsoft.Compute/virtualMachines/mylab --username my_user_name --auth-type password should connect to VM via ssh via bastion-host-paas-service

Environment Summary

myuser@ntb1234 ~ $ az version
{
  "azure-cli": "2.65.0",
  "azure-cli-core": "2.65.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "aks-preview": "9.0.0b6",
    "azure-devops": "1.0.1",
    "azure-firewall": "1.2.0",
    "bastion": "1.3.1",
    "containerapp": "1.0.0b3",
    "ssh": "2.0.5"
  }
}

Additional context

It seems as root cause from several others issues, which are reported.

yonzhan commented 1 day ago

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

microsoft-github-policy-service[bot] commented 1 day ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bastionsuppgithub.

ferben commented 1 day ago

I have the same issue. Azure-CLI installed using Hombrew on DevOps self-hosted agent works fine at least Friday 18th October at 6:43 PM (CET) and stops working 20th October at 2:30 AM (CET). So between these dates something must happens. Azure-CLI files (readme, binary, libraries inside .../Cellar/azure-cli/*) has been changed Saturday 19th at 5:58 PM (CET).

ferben commented 1 day ago

This is the fix: https://github.com/Azure/azure-cli/issues/30127#issuecomment-2425812364