Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

_load_user_token base_path = self._get_base_path(self._user.path) AttributeError: 'str' object has no attribute 'path' #182

Closed
max-allan-surevine opened this issue Feb 10, 2020 · 9 comments
Assignees
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@max-allan-surevine
Copy link

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from kubernetes import config
>>> config.load_kube_config('/tmp/kubeconfig')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 649, in load_kube_config
    loader.load_and_set(config)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 461, in load_and_set
    self._load_authentication()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 205, in _load_authentication
    if self._load_user_token():
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 395, in _load_user_token
    base_path = self._get_base_path(self._user.path)
AttributeError: 'str' object has no attribute 'path'

Kubeconfig :

Kind: config
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0...Qo=
    server: https://0...C.sk1.eu-west-2.eks.amazonaws.com
  name: k8s
contexts:
- context:
    cluster: k8s
    user: aws
  name: aws
current-context: aws
users:
- name: aws
  user: lambda

This used to work with previous versions.
Other people have the same issue, "resolved" by pinning to version 9 of kubernetes.
aws-samples/amazon-k8s-node-drainer#14

@roycaihw
Copy link
Member

roycaihw commented Mar 2, 2020

/assign

@roycaihw
Copy link
Member

roycaihw commented Mar 3, 2020

This is a regression introduced in #94.

Technically a user with a string value (user: lambda) doesn't provide any auth info, and when we _load_authentication it should be a noop. _get_base_path expects path from _user because in most cases _user would be a dict or list, which gets converted to a ConfigNode.

A workaround is to change your kubeconfig to make user a dict or a list, instead of a string. E.g.

users:
- name: aws
  user:
    name: lambda

We should fix the behavior in this client and add a test. I can think of either constructing a ConfigNode around the string value, or skipping _load_user_token when _user doesn't have those token keys. I need to think which way makes more sense.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 1, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 1, 2020
@max-allan-surevine
Copy link
Author

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 3, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 1, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 31, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants