python icon indicating copy to clipboard operation
python copied to clipboard

Fix: correect header retrieval for urllib3 compatibility

Open franck-ada opened this issue 1 month ago • 5 comments

What type of PR is this? /kind bug /kind deprecation

What this PR does / why we need it: Correct issue link to upgrade of urlib3

Which issue(s) this PR fixes: Fixes #2280 / #2477

Special notes for your reviewer: Does this PR introduce a user-facing change? NONE

franck-ada avatar Dec 08 '25 03:12 franck-ada

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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-sigs/prow repository.

k8s-ci-robot avatar Dec 08 '25 03:12 k8s-ci-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: franck-ada Once this PR has been reviewed and has the lgtm label, please assign yliaog for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Dec 08 '25 03:12 k8s-ci-robot

Here is another occurrence of getheaders: https://github.com/kubernetes-client/python/blob/a49d85dbc593e083974099e766809c7b13b243de/kubernetes/client/exceptions.py#L91

From my sniff testing, this needs to be changed as well.

efussi avatar Dec 08 '25 11:12 efussi

http_resp

I was looking at it. this http_resp is an instance of RESTResponse so it should stay as it is

franck-ada avatar Dec 09 '25 02:12 franck-ada

http_resp

I was looking at it. this http_resp is an instance of RESTResponse so it should stay as it is

@franck-ada I was testing an ansible playbook with urllib3 2.6.0 patched like this:

sed -i -e 's/urllib3_response.getheaders()/urllib3_response.headers/' -e 's/urllib3_response.getheader(name, default)/urllib3_response.headers.get(name, default)/' \
    $site_packages/kubernetes/client/rest.py

When trying to delete a configmap that doesn't exist through ansible's k8s task, I still got this error:

TASK [wca-base : Delete configmap in dev] *************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! =>                           
    ansible_facts:                                                                                                             
        discovered_interpreter_python: /home/vagrant/.cache/venv/ansible/bin/python3.12                                        
    changed: false                                                                                                             
    msg: 'Failed to retrieve requested object: ''HTTPResponse'' object has no attribute                                                                                                                                                                       
        ''getheaders'''                                                                                                                                                                                                                                       

I had to add this additional patch to get past this error:

sed -i -e 's/http_resp.getheaders()/http_resp.headers/' \
    $site_packages/kubernetes/client/exceptions.py

Unfortunately, I didn't find a way yet to have ansible print the full stack trace.

efussi avatar Dec 09 '25 08:12 efussi