Azure / Azure/azure-iot-ops-cli-extension

[bug] init command fails if kube-config does not contain the selected cluster

Open
#109 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16
Forks
20
Avg merge
2d 5h
Merged PRs (30d)
11

Description

**Describe the bug**
The command az iot ops init fails if kube-config does not contain the selected cluster.

**To Reproduce**
Steps to reproduce the behavior:

1. Person A creates a new arc-enabled AKS Edge Essentials system
2. Person B wants to install Azure IoT Operations on this existing system
3. Since Person B never used the system, it cannot be found within kube-config
4. See error

**Expected behavior**
Instead of the python error, there should be some user friendly error message with an example on how to get the credentials of the cluster. This example could be filled with all the parameters which are provided anyway.

**Screenshots**
```bash
az iot ops init --subscription xxxxx -g rg-xxxxx --cluster xxxxx-aksee001 --kv-id /subscriptions/xxxxx/resourceGroups/rg-xxxxx/providers/Microsoft.KeyVault/vaults/kv-xxxxx --no-deploy
Command group 'iot ops' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
Invalid kube-config file. No configuration found.
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "C:\Users\xxxxx\.azure\cliextensions\azure-iot-ops\azext_edge\edge\commands_edge.py", line 128, in init
load_config_context(context_name=context_name)
File "C:\Users\xxxxx\.azure\cliextensions\azure-iot-ops\azext_edge\edge\providers\base.py", line 41, in load_config_context
config.load_kube_config(context=context_name)
File "C:\Users\xxxxx\.azure\cliextensions\azure-iot-ops\kubernetes\config\kube_config.py", line 815, in load_kube_config
loader = _get_kube_config_loader(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxxxx\.azure\cliextensions\azure-iot-ops\kubernetes\config\kube_config.py", line 772, in _get_kube_config_loader
raise ConfigException(
kubernetes.config.config_exception.ConfigException: Invalid kube-config file. No configuration found.
```

**Environment (please complete the following information):**

- OS: Windows 10 Enterprise
- Shell: powershell
- Az CLI version: 2.54.0
- IoT extension version: 0.1.0b2

Contributor guide

Open the contributing guide

Research direction

Start at the init entry point in azext_edge/edge/commands_edge.py and follow load_config_context in azext_edge/edge/providers/base.py into kubernetes/config/kube_config.py. Reproduce the command with a kube-config that lacks the selected cluster, then verify that the missing configuration produces a user-friendly message with an example for obtaining cluster credentials instead of a traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.