-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Empty auth-provider/config key raises ConfigException #328
Comments
It is a reasonable request to have getitem allow empty dict. I say we should check check for if v is not None: ... |
Cool. I'm not terribly concerned if there is an incoming fix or not, but hopefully this issue documents an ok (findable!) workaround so others don't stumble as much as I did. |
/assign @iamneha |
@iamneha: GitHub didn't allow me to assign the following users: iamneha. Note that only kubernetes-client members and repo collaborators can be assigned. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@pbrumblay I don't think it's a good to have a work around instead of a fix. The library should be able to read config files which are generated/read by other standard kubernetes tools, and kubectl reads this just fine. This bug doesn't exist in version |
@pvanderlinden Great! I'm glad it's been fixed. I've moved on from this work and don't have time to verify it. Feel free to close this. As I said above, I mainly opened this to save others pain.
|
@pbrumblay It's not actually fixed. That's just an older version which doesn't have the bug. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I'm trying to write a dockerized application to crawl k8s clusters and extract configuration information. I don't wish to install gcloud/kubectl in the application container so I'm following this suggestion on constructing a kube config file: kubernetes/kubernetes#30617 (comment)
With this config file:
And this code:
I get this error:
The key is present - what the heck? This threw me for a while until I cracked open the code.
I believe this is because line 203 of https://github.com/kubernetes-client/python-base/blob/ab3fc5446714ac19100c0f97072c53cbd81c3b87/config/kube_config.py sets the value to the empty dict {} and line 287 in
__getitem__
only tests for boolean true (and empty dicts are False in python).My workaround is to add a bogus attribute under config to my yaml file to make the dict non-empty. It appears that the intent is to allow people to have missing/empty/invalid/expired auth-provider/config entries and to then generate the config entry when such a case is detected. I'm new to python but I suppose this is a common problem because of the way that python evaluates empty dicts to False.
I'm not sure what the right fix would be, whether to have
__getitem__
allow empty structures or to simply add a bogus value to make the dict non-empty in line 203. Or maybe I should have just known this and tried adding a bogus attribute to config right off the bat...The text was updated successfully, but these errors were encountered: