Azure / Azure/azure-cli

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

Open
#28,831 4 comments 0 reactions 0 assignees View on GitHub
act-observability-squad AKS Auto-Assign Auto-Resolve bug customer-reported Possible-Solution Service Attention Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

Hello,

when running `az aks install-cli` while `cloud` is set to `AzureChinaCloud` the following error occurs:
```bash
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

```bash
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

```bash
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 [, , ]
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 []
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 [.add_subscription_parameter at 0xffff878a2de0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0xffff878c6020>, .add_cache_arguments at 0xffff878c6160>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .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 []
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.