Repository navigation
Closed
Labels
Milestone
Description
Double dash CLI arguments --config and --kubeconfig do not work as expected. Is seems that they are not recognized by the script k8s-version-recency-check.py.
See the STDOUT when --config is used:
$ python kaas/k8s-version-recency/k8s-version-recency-check.py --config config.yaml -k kubeconfig.yaml
The config file under couldn't be found, falling back to the default config.
See the STDOUT when --kubeconfig is used:
$ python kaas/k8s-version-recency/k8s-version-recency-check.py -c config.yaml --kubeconfig kubeconfig.yaml
WARNING: Config not found:
Traceback (most recent call last):
File "/home/mato/Dev/ifne/scs/standards/Tests/kaas/k8s-version-recency/k8s-version-recency-check.py", line 467, in <module>
return_code = asyncio.run(main(sys.argv[1:]))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/mato/Dev/ifne/scs/standards/Tests/kaas/k8s-version-recency/k8s-version-recency-check.py", line 445, in main
cluster_version, cluster_name = await get_k8s_cluster_version(config.kubeconfig)
File "/home/mato/Dev/ifne/scs/standards/Tests/kaas/k8s-version-recency/k8s-version-recency-check.py", line 380, in get_k8s_cluster_version
cluster_config = await kubernetes_asyncio.config.load_kube_config(kubeconfig)
File "/home/mato/Dev/ifne/scs/standards/.venv/lib/python3.10/site-packages/kubernetes_asyncio/config/kube_config.py", line 598, in load_kube_config
loader = _get_kube_config_loader_for_yaml_file(
File "/home/mato/Dev/ifne/scs/standards/.venv/lib/python3.10/site-packages/kubernetes_asyncio/config/kube_config.py", line 562, in _get_kube_config_loader_for_yaml_file
return KubeConfigLoader(
File "/home/mato/Dev/ifne/scs/standards/.venv/lib/python3.10/site-packages/kubernetes_asyncio/config/kube_config.py", line 149, in __init__
self.set_active_context(active_context)
File "/home/mato/Dev/ifne/scs/standards/.venv/lib/python3.10/site-packages/kubernetes_asyncio/config/kube_config.py", line 160, in set_active_context
context_name = self._config['current-context']
File "/home/mato/Dev/ifne/scs/standards/.venv/lib/python3.10/site-packages/kubernetes_asyncio/config/kube_config.py", line 447, in __getitem__
raise ConfigException(
kubernetes_asyncio.config.config_exception.ConfigException: Invalid kube-config file. Expected key current-context in kube-config
Single-dash versions -c and -k work as expected.
Notes:
- it would be great to improve error handling in the case when the kubeconfig is not found
- why not to use argparse python builtin lib for parsing the args?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
mbuechse commentedon Mar 4, 2024
As far as I can tell, the
k8s-recency-check.pyis being superseded soon by PR standards/#488. The use ofgetoptis due to historical reasons, I guess, but if we really switch to another library, we can as well go forclick(which is already being used by the new flavor-name cli).cah-hbaum commentedon Mar 4, 2024
Yeah
getoptwas more due to historical reasons and the test is superseded soon as @mbuechse mentioned.Also, in the future, we probably want to convert this test to Golang in order to make it better integrated with Sonobuoy.
mbuechse commentedon Mar 4, 2024
FYI, the error is in this line
It should read
And any extraneous arguments (
argsnot empty) should lead to a critical error.matofeder commentedon Mar 4, 2024
@mbuechse, @cah-hbaum thanks for your quick reponses!
Then I would say we can close this one after #488 is merged because I see it as irrelevant then.
mbuechse commentedon Mar 4, 2024
@matofeder Well, thanks very much for spotting the error!
martinmo commentedon Mar 5, 2024
Closing this because #488 was merged.
Fix parsing of double dash CLI arguments
Restore scs-0210-v1 conformance tests (#503)