[az fleet] get-credentials command fails with error with empty kubeconfig #7437
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.
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 asclusters
. For example: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
The text was updated successfully, but these errors were encountered: