Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[az fleet] get-credentials command fails with error with empty kubeconfig #7437

Closed
Ealianis opened this issue Mar 29, 2024 · 2 comments
Closed
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Service Attention This issue is responsible by Azure service team.

Comments

@Ealianis
Copy link
Contributor

Ealianis commented Mar 29, 2024

Describe the bug

When calling az fleet get-credentials -g $groupName -n $fleetname. It is possible for an error to occur. When a user adds or removes clusters with tooling, such as kind.io, the cleanup of the KubeConfig can lead to removed root fields such as clusters. For example:

apiVersion: v1
# missing `clusters` key
kind: Config
preferences: {}

Regardless how the kubeconfig lands in such state, the command fails to handle it properly.

Related command

az fleet get-credentials

Errors

Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 664, in execute
raise ex
File "/usr/local/Cellar/azure-cli/2.58.0/libexec/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 "/usr/local/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 701, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 334, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/azure-cli/2.58.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/Users/arvind/.azure/cliextensions/fleet/azext_fleet/custom.py", line 212, in get_credentials
print_or_merge_credentials(
File "/Users/arvind/.azure/cliextensions/fleet/azext_fleet/_helpers.py", line 47, in print_or_merge_credentials
_merge_kubernetes_configurations(
File "/Users/arvind/.azure/cliextensions/fleet/azext_fleet/_helpers.py", line 84, in _merge_kubernetes_configurations
_handle_merge(existing, addition, 'clusters', replace)
File "/Users/arvind/.azure/cliextensions/fleet/azext_fleet/_helpers.py", line 110, in _handle_merge
if existing[key] is None:
~~~~~~~~^^^^^
KeyError: 'clusters'

Issue script & Debug output

n/a the error message above is sufficient.

Expected behavior

The command should account for missing fields within the kubeconfig, it should not fail if the key does not exist.

Environment Summary

azure-cli 2.58.0

core 2.58.0
telemetry 1.1.0

Extensions:
fleet 1.0.5

Dependencies:
msal 1.26.0
azure-mgmt-resource 23.1.0b2

Additional context

No response

@Ealianis Ealianis added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Mar 29, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 29, 2024

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

@Ealianis
Copy link
Contributor Author

@yonzhan , I am a maintainer for the extension, please assign the bug to me.

@yonzhan yonzhan added the Service Attention This issue is responsible by Azure service team. label Mar 29, 2024
@Ealianis Ealianis closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants