Skip to content

Kubernetes Clients breaks with urllib3 2.6.0 #2477

@potiuk

Description

@potiuk

What happened (please include outputs or screenshots):

When urllib3 2.6.0 is used with kubernetes client, it fails because internally it uses "getheaders()" which have been deprecated in 2.0.0 and removed in 2.6.0 .

The offending line is:

self.headers = http_resp.getheaders()

Possibly there are other pleaces.

When there is an API exception returned and urllib 2.6.0 you get an exception:

../.venv/lib/python3.10/site-packages/kubernetes/client/api/core_v1_api.py:23999: in read_namespaced_pod
    return self.read_namespaced_pod_with_http_info(name, namespace, **kwargs)  # noqa: E501
../.venv/lib/python3.10/site-packages/kubernetes/client/api/core_v1_api.py:24086: in read_namespaced_pod_with_http_info
    return self.api_client.call_api(
../.venv/lib/python3.10/site-packages/kubernetes/client/api_client.py:348: in call_api
    return self.__call_api(resource_path, method,
../.venv/lib/python3.10/site-packages/kubernetes/client/api_client.py:180: in __call_api
    response_data = self.request(
../.venv/lib/python3.10/site-packages/kubernetes/client/api_client.py:373: in request
    return self.rest_client.GET(url,
../.venv/lib/python3.10/site-packages/kubernetes/client/rest.py:244: in GET
    return self.request("GET", url,
../.venv/lib/python3.10/site-packages/kubernetes/client/rest.py:238: in request
    raise ApiException(http_resp=r)
../.venv/lib/python3.10/site-packages/kubernetes/client/exceptions.py:91: in __init__
    self.headers = http_resp.getheaders()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <kubernetes.client.rest.RESTResponse object at 0x7f0b51d92c50>

    def getheaders(self):
        """Returns a dictionary of the response headers."""
>       return self.urllib3_response.getheaders()
E       AttributeError: 'HTTPResponse' object has no attribute 'getheaders'. Did you mean: 'headers'?

What you expected to happen:

No crash on missing attribute.

How to reproduce it (as minimally and precisely as possible):

I have no minimal reproducer - it started to fail in our CI: https://github.com/apache/airflow/actions/runs/19969105384/job/57271505761#step:7:963 - however the error is pretty obvious:

  • install kubernetes-client
  • install urllib3 2.6.0
  • make any call that raises APIException -> crash.

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version): v1.30.13 for example (crashes for all of them)
  • OS (e.g., MacOS 10.13.6): Debian Bookworm
  • Python version (python --version) 3.10.19
  • Python client version (pip list | grep kubernetes) kubernetes==33.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions