Azure / azure-capi-cli-extension

Kubernetes Cluster API support in the Azure CLI
MIT License
20 stars 17 forks source link

Doesn't play nice with aks-preview extension #197

Open mboersma opened 1 year ago

mboersma commented 1 year ago

With the latest aks-preview CLI extension installed, az capi create emits an error:

Extension 'capi' 0.1.5 is already installed.
Using /home/marosset/src/github.com/marosset/windows-testing/capz/templates/windows-ci.yaml
Command group 'capi' is in preview and under development. Reference and support levels:
https://aka.ms/CLI_refstatus

Could not find an Azure resource group, CAPZ will create one for you
Could not find an Azure resource group, CAPZ will create one for you
✓ Created resource group capz-conf-cq5eie
✓ Created Azure management cluster with AKS
The command failed with an unexpected error. Here is the traceback:
Command '['az', 'network', 'vnet', 'list', '--resource-group', 'WARNING: The behavior of this command has been altered by the following extension: aks-preview\nMC_capz-conf-cq5eie_capi-manager_westus2', '--query', "[?starts_with(name, 'aks-vnet-')].name | [0]", '--output', 'tsv']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/custom.py", line 491, in create_workload_cluster
    if not init_environment(cmd, not yes, management_cluster_name, management_cluster_resource_group_name,
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/custom.py", line 88, in init_environment
    if use_new_cluster and not create_new_management_cluster(cmd, management_cluster_name,
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/custom.py", line 209, in create_new_management_cluster
    if not create_aks_management_cluster(cmd, cluster_name, resource_group_name,
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/custom.py", line 177, in create_aks_management_cluster
    os.environ[AKS_VNET_NAME] = find_aks_vnet_name(aks_infra_rg_name)
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/custom.py", line 156, in find_aks_vnet_name
    return run_shell_command(command).strip()
  File "/home/marosset/.azure/cliextensions/capi/azext_capi/helpers/run_command.py", line 22, in run_shell_command
    output = subprocess.check_output(command, universal_newlines=True, stderr=stderr)
  File "/opt/az/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/opt/az/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['az', 'network', 'vnet', 'list', '--resource-group', 'WARNING: The behavior of this command has been altered by the following extension: aks-preview\nMC_capz-conf-cq5eie_capi-manager_westus2', '--query', "[?starts_with(name, 'aks-vnet-')].name | [0]", '--output', 'tsv']' returned non-zero exit status 1.

Seems to work again when aks-preview is removed.

cc: @marosset