azure-cli: az ask get credentials crashing

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az aks get-credentials

Errors:

The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory: ''
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/acs/custom.py", line 2163, in aks_get_credentials
    _print_or_merge_credentials(
  File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/acs/custom.py", line 3572, in _print_or_merge_credentials
    with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY, 0o600), 'wt'):
FileNotFoundError: [Errno 2] No such file or directory: ''

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az aks get-credentials --resource-group {} --name {} --admin

Expected Behavior

Environment Summary

macOS-12.0.1-x86_64-i386-64bit, Darwin 21.1.0
Python 3.10.0
Installer: HOMEBREW

azure-cli 2.31.0

Extensions:
interactive 0.4.5
fzf 1.0.2

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I’ve been experiencing the same issue as the reporter, and I’ve traced the issue to the fact that my KUBECONFIG env var has a leading colon (:). Once I remove that leading colon, az aks get-credentials works as expected.

I don’t think my KUBECONFIG export statement has changed recently, and I recall doing a get-credentials within the last couple of months, so I’m wondering whether this is a regression in how KUBECONFIG is being parsed. kubectl has no problem with my KUBECONFIG env var and works as expected.

This line in my .zshrc is resulting in the leading colon due to $KUBECONFIG being undefined by default:

export KUBECONFIG=$KUBECONFIG:$HOME/.kube/config1:$HOME/.kube/config2

This results in:

> echo $KUBECONFIG
:/Users/myuser/.kube/config1:/Users/myuser/.kube/config2

Azure CLI version:

> az version
{
  "azure-cli": "2.32.0",
  "azure-cli-core": "2.32.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

Full stack trace:

The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory: ''
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/acs/custom.py", line 2164, in aks_get_credentials
    _print_or_merge_credentials(
  File "/usr/local/Cellar/azure-cli/2.32.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/acs/custom.py", line 3575, in _print_or_merge_credentials
    with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY, 0o600), 'wt'):
FileNotFoundError: [Errno 2] No such file or directory: ''