Skip to content
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

Trailing slash on kube/config causes failures. #388

Closed
karlbunch opened this issue Nov 11, 2017 · 4 comments
Closed

Trailing slash on kube/config causes failures. #388

karlbunch opened this issue Nov 11, 2017 · 4 comments

Comments

@karlbunch
Copy link

Using the example1 code if your ~/.kube/config has an ending slash in the URL you get this failure:

Listing pods with their IPs:
Traceback (most recent call last):
  File "example1.py", line 33, in <module>
    main()
  File "example1.py", line 26, in main
    ret = v1.list_pod_for_all_namespaces(watch=False)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/apis/core_v1_api.py", line 13589, in list_pod_for_all_namespaces
    (data) = self.list_pod_for_all_namespaces_with_http_info(**kwargs)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/apis/core_v1_api.py", line 13686, in list_pod_for_all_namespaces_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py", line 321, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py", line 155, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/api_client.py", line 342, in request
    headers=headers)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/rest.py", line 231, in GET
    query_params=query_params)
  File "/usr/local/lib/python3.5/dist-packages/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 11 Nov 2017 17:43:55 GMT', 'Content-Length': '524', 'Content-Type': 'application/json'})
HTTP response body: {
  "paths": [
    "/apis",
    "/apis/",
    "/apis/apiextensions.k8s.io",
    "/apis/apiextensions.k8s.io/v1beta1",
    "/healthz",
    "/healthz/etcd",
    "/healthz/ping",
    "/healthz/poststarthook/generic-apiserver-start-informers",
    "/healthz/poststarthook/start-apiextensions-controllers",
    "/healthz/poststarthook/start-apiextensions-informers",
    "/metrics",
    "/swagger-2.0.0.json",
    "/swagger-2.0.0.pb-v1",
    "/swagger-2.0.0.pb-v1.gz",
    "/swagger.json",
    "/swaggerapi",
    "/version"
  ]
}
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ...
    server: https://master.example.net:6443/
  name: master.example.net

If you remove the trailing slash in the config file it works fine. kubectl has no issue with the trailing slash.

@karlbunch
Copy link
Author

karlbunch commented Nov 11, 2017

Looks like just adding rstrip('/') here fixes it:

    def _load_cluster_info(self):
        if 'server' in self._cluster:
            self.host = self._cluster['server'].rstrip('/')

https://github.com/kubernetes-client/python-base/blob/a41c44715241552de73361673152f3f0d0bb9bc4/config/kube_config.py#L227

@tomplus
Copy link
Member

tomplus commented Nov 12, 2017

This issue is related to #375

@roycaihw
Copy link
Member

Fixed by kubernetes-client/python-base#45. Closing

/close

@k8s-ci-robot
Copy link
Contributor

@roycaihw: Closing this issue.

In response to this:

Fixed by kubernetes-client/python-base#45. Closing

/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.

EarthmanT pushed a commit to cloudify-cosmo/cloudify-kubernetes-plugin that referenced this issue Jun 4, 2020
EarthmanT added a commit to cloudify-cosmo/cloudify-kubernetes-plugin that referenced this issue Jun 14, 2020
* handle this error:

kubernetes-client/python#388

* getting started

need to figure out what is the right way to handle the delete when there is ambiguety in the resources

* finished adding the search for resource ID stuff

* works for single resources

* works - will fix the tests later

* fix testss

* trying that

* trying to make this work in python3

* final changes
yliaog pushed a commit to yliaog/client-python that referenced this issue Jan 8, 2022
yliaog pushed a commit to yliaog/client-python that referenced this issue Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants