-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
python kubeconfig loading doesn't match kubectl config loading... #445
python kubeconfig loading doesn't match kubectl config loading... #445
Comments
The config loader https://github.com/kubernetes/kubernetes/blob/b114a117f8688310b9162961d8e9b15192eacd50/pkg/kubectl/cmd/util/factory_client_access.go#L175-L176 I agree it should detect duplicate entries. Just curious would it solve the problem if the python client chose the last one in the file? |
@brendandburns Totally agree. Just curious if |
Automatic merge from submit-queue (batch tested with PRs 63598, 63913, 63459, 63963, 60464). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Client-go raises error on duplicated name in kubeconfig (for NamedCluster, NamedContext, NamedUser, NamedExtension) **What this PR does / why we need it**: Client should detect duplicated name when loading `name-value` based lists in kubeconfig: `users`, `clusters`, `contexts`. Currently if there are multiple value with same name, `client-python` will pick the first one, while `client-go` will pick the last. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes-client/python#445, kubernetes-client/python-base#47 **Special notes for your reviewer**: **Release note**: ```release-note kubectl and client-go now detects duplicated name for user, cluster and context when loading kubeconfig and reports error ``` /sig api-machinery cc @brendandburns @mbohlool
Automatic merge from submit-queue (batch tested with PRs 63598, 63913, 63459, 63963, 60464). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Client-go raises error on duplicated name in kubeconfig (for NamedCluster, NamedContext, NamedUser, NamedExtension) **What this PR does / why we need it**: Client should detect duplicated name when loading `name-value` based lists in kubeconfig: `users`, `clusters`, `contexts`. Currently if there are multiple value with same name, `client-python` will pick the first one, while `client-go` will pick the last. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes-client/python#445, kubernetes-client/python-base#47 **Special notes for your reviewer**: **Release note**: ```release-note kubectl and client-go now detects duplicated name for user, cluster and context when loading kubeconfig and reports error ``` /sig api-machinery cc @brendandburns @mbohlool Kubernetes-commit: 7909712ca574c536901bc7858dfbf72a3a6ee7dd
Automatic merge from submit-queue (batch tested with PRs 63598, 63913, 63459, 63963, 60464). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Client-go raises error on duplicated name in kubeconfig (for NamedCluster, NamedContext, NamedUser, NamedExtension) **What this PR does / why we need it**: Client should detect duplicated name when loading `name-value` based lists in kubeconfig: `users`, `clusters`, `contexts`. Currently if there are multiple value with same name, `client-python` will pick the first one, while `client-go` will pick the last. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes-client/python#445, kubernetes-client/python-base#47 **Special notes for your reviewer**: **Release note**: ```release-note kubectl and client-go now detects duplicated name for user, cluster and context when loading kubeconfig and reports error ``` /sig api-machinery cc @brendandburns @mbohlool Kubernetes-commit: 7909712ca574c536901bc7858dfbf72a3a6ee7dd
Automatic merge from submit-queue (batch tested with PRs 63598, 63913, 63459, 63963, 60464). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Client-go raises error on duplicated name in kubeconfig (for NamedCluster, NamedContext, NamedUser, NamedExtension) **What this PR does / why we need it**: Client should detect duplicated name when loading `name-value` based lists in kubeconfig: `users`, `clusters`, `contexts`. Currently if there are multiple value with same name, `client-python` will pick the first one, while `client-go` will pick the last. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes-client/python#445, kubernetes-client/python-base#47 **Special notes for your reviewer**: **Release note**: ```release-note kubectl and client-go now detects duplicated name for user, cluster and context when loading kubeconfig and reports error ``` /sig api-machinery cc @brendandburns @mbohlool Kubernetes-commit: 7909712ca574c536901bc7858dfbf72a3a6ee7dd
I had a .kube/config file with duplicate clusters with the same name (but different information) in the config file, the three different entries each pointed to different clusters, two were dead, but one was alive (I had be repeatedly creating and deleting clusters)
kubectl
command line happened to chose the working one and worked correctly.python client library chose the first one in the file (which wasn't working) and failed.
This lead to a very confused experience until I figured out what was going on.
It will be difficult to emulate the
kubectl
parsing exactly, but we should detect duplicate entries and throw an exception. (and I would argue thatkubectl
probably should too)This actually probably applies to all client libraries in different languages.
@mbohlool
The text was updated successfully, but these errors were encountered: