Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

`az aks install-cli` fails installing `kubectl` in `AzureChinaCloud`- 404 NotFound #28831

Open iLem0n opened 4 months ago

iLem0n commented 4 months ago

Describe the bug

Hello,

when running az aks install-cli while cloud is set to AzureChinaCloud the following error occurs:

The detected architecture of current device is "aarch64", and the binary for "arm64" will be downloaded. If the detection is wrong, please download and install the binary corresponding to the appropriate architecture.
No version specified, will get the latest version of kubectl from "https://mirror.azure.cn/kubernetes/kubectl/stable.txt"
Downloading client to "/usr/local/bin/kubectl" from "https://mirror.azure.cn/kubernetes/kubectl/v1.30.0/bin/linux/arm64/kubectl"
Connection error while attempting to download client (HTTP Error 404: Not Found)

It seem that mirror.azure.cn only hosts the amd64-binaries, thus it cannot be used in AzureChinaCloud on any other hardware then amd64.

Related command

az cloud set --name AzureChinaCloud az aks install-cli

Errors

The detected architecture of current device is "aarch64", and the binary for "arm64" will be downloaded. If the detection is wrong, please download and install the binary corresponding to the appropriate architecture.
No version specified, will get the latest version of kubectl from "https://mirror.azure.cn/kubernetes/kubectl/stable.txt"
Downloading client to "/usr/local/bin/kubectl" from "https://mirror.azure.cn/kubernetes/kubectl/v1.30.0/bin/linux/arm64/kubectl"
Connection error while attempting to download client (HTTP Error 404: Not Found)

Issue script & Debug output

cli.knack.cli: Command arguments: ['aks', 'install-cli', '--client-version', 'v1.30.0', '--kubelogin-version', 'v0.1.3', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0xffff88ba80e0>, <function OutputProducer.on_global_arguments at 0xffff88b36200>, <function CLIQuery.on_global_arguments at 0xffff88b6fce0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'aks': ['azure.cli.command_modules.acs']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: acs                       0.031        14        76
cli.azure.cli.core: Total (1)                 0.031        14        76
cli.azure.cli.core: Loaded 14 groups, 76 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : aks install-cli
cli.azure.cli.core: Command table: aks install-cli
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0xffff87ac9d00>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/root/.azure/commands/2024-04-25.08-49-01.aks_install-cli.38621.log'.
az_command_data_logger: command args: aks install-cli --client-version {} --kubelogin-version {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0xffff878a2de0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0xffff878c6020>, <function register_cache_arguments.<locals>.add_cache_arguments at 0xffff878c6160>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0xffff88b362a0>, <function CLIQuery.handle_query_parameter at 0xffff88b6fd80>, <function register_ids_argument.<locals>.parse_ids_arguments at 0xffff878c60c0>]
cli.azure.cli.command_modules.acs.custom: The detected architecture of current device is "aarch64", and the binary for "arm64" will be downloaded. If the detection is wrong, please download and install the binary corresponding to the appropriate architecture.
cli.azure.cli.command_modules.acs.custom: Downloading client to "/usr/local/bin/kubectl" from "https://mirror.azure.cn/kubernetes/kubectl/v1.30.0/bin/linux/arm64/kubectl"
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/custom.py", line 1876, in k8s_install_kubectl
    _urlretrieve(file_url, install_location)
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/custom.py", line 1972, in _urlretrieve
    req = urlopen(url, context=_ssl_context())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/opt/az/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

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 664, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, 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 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, 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 "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/custom.py", line 1698, in k8s_install_cli
    k8s_install_kubectl(cmd, client_version, install_location, base_src_url, arch=arch)
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acs/custom.py", line 1880, in k8s_install_kubectl
    raise CLIError(
knack.util.CLIError: Connection error while attempting to download client (HTTP Error 404: Not Found)

cli.azure.cli.core.azclierror: Connection error while attempting to download client (HTTP Error 404: Not Found)
az_command_data_logger: Connection error while attempting to download client (HTTP Error 404: Not Found)
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0xffff87ac9f80>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 3.726 seconds (init: 0.115, invoke: 3.610)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3790 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /root/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

Install kubectl & kubelogin while cloud id set to AzureChinaCloud

Environment Summary

azure-cli 2.59.0

core 2.59.0 telemetry 1.1.0

Dependencies: msal 1.27.0 azure-mgmt-resource 23.1.0b2

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

Python (Linux) 3.11.8 (main, Mar 27 2024, 04:05:57) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 4 months ago

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

azure-client-tools-bot-prd[bot] commented 4 months ago
Hi @iLem0n Find similar issue https://github.com/Azure/azure-cli/issues/23405.
Issue title az aks install-cli failed
Create time 2022-08-02
Comment number 5

Possible solution: The error message in the new issue is similar to the error message in the old issue. In the old issue, the user was trying to download kubectl from a URL that did not have the appropriate binary for their operating system. Similarly, in the new issue, the user is trying to download kubectl from a URL that only has the binary for "amd64" architecture, while the user's device has "aarch64" architecture.

The solution to the old issue was to install kubectl via Homebrew. This solution can also be applied to the new issue. Alternatively, the user can follow the steps mentioned in the Kubernetes documentation to install kubectl on macOS.


Please confirm if this resolves your issue.

microsoft-github-policy-service[bot] commented 4 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dyu1208, @FumingZhang, @andyliuliming.

iLem0n commented 4 months ago

Hi @iLem0n Find similar issue #23405.

Issue title az aks install-cli failed Create time 2022-08-02 Comment number 5 Possible solution: The error message in the new issue is similar to the error message in the old issue. In the old issue, the user was trying to download kubectl from a URL that did not have the appropriate binary for their operating system. Similarly, in the new issue, the user is trying to download kubectl from a URL that only has the binary for "amd64" architecture, while the user's device has "aarch64" architecture.

The solution to the old issue was to install kubectl via Homebrew. This solution can also be applied to the new issue. Alternatively, the user can follow the steps mentioned in the Kubernetes documentation to install kubectl on macOS.

Please confirm if this resolves your issue.

Im running the client installation within a dev container (mcr.microsoft.com/devcontainers/base:jammy) as part of the preparation phase for my project specific automation scripts, thus its not about installing it on a macOS in general.

So at least it's ubuntu on arm64 hardware.