Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Allow creation of new management cluster without kubectl context #195

Open
dtzar opened this issue May 23, 2023 · 0 comments
Open

Allow creation of new management cluster without kubectl context #195

dtzar opened this issue May 23, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@dtzar
Copy link

dtzar commented May 23, 2023

Running az capi management create ... on an orchestrator such as a GitHub action runner which has kubectl without any context crashes the cli and prohibits a new AKS management cluster from being created. The kubectl context shouldn't matter as it would get set to the new aks cluster which gets created to then be able to do a clusterctl init against it.

Error message:

error: current-context is not set
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: Command '['kubectl', 'config', 'current-context']' 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 7[26](https://github.com/samirbanjanovic/infrastructure-platform/actions/runs/5062290266/jobs/9087622146#step:6:27), 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 [33](https://github.com/samirbanjanovic/infrastructure-platform/actions/runs/5062290266/jobs/9087622146#step:6:34)3, 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 "/opt/az/azcliextensions/capi/azext_capi/custom.py", line 126, in create_management_cluster
    existing_cluster = kubectl_helpers.find_cluster_in_current_context()
  File "/opt/az/azcliextensions/capi/azext_capi/helpers/kubectl.py", line 65, in find_cluster_in_current_context
    current_context = find_kubectl_current_context()
  File "/opt/az/azcliextensions/capi/azext_capi/helpers/kubectl.py", line [37](https://github.com/samirbanjanovic/infrastructure-platform/actions/runs/5062290266/jobs/9087622146#step:6:38), in find_kubectl_current_context
    output = run_shell_command(command)
  File "/opt/az/azcliextensions/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 [42](https://github.com/samirbanjanovic/infrastructure-platform/actions/runs/5062290266/jobs/9087622146#step:6:43)1, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/opt/az/lib/python3.10/subprocess.py", line [52](https://github.com/samirbanjanovic/infrastructure-platform/actions/runs/5062290266/jobs/9087622146#step:6:53)6, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['kubectl', 'config', 'current-context']' returned non-zero exit status 1.
@dtzar dtzar added the bug Something isn't working label May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant