Skip to content

Upgrade to openapi-generator >= v6.4.0: DeprecationWarning: HTTPResponse.getheaders() is deprecated #2101

Open

Description

@sergiitk

What happened (please include outputs or screenshots):
Certain k8s API calls (f.e. deleting a namespace) result in the following deprecation warnings:

venv-test/lib/python3.9/site-packages/kubernetes/client/rest.py:44: DeprecationWarning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.
  return self.urllib3_response.getheaders()

F.e., see at the bottom of this test log: https://source.cloud.google.com/results/invocations/0cb2a704-d3b4-40a5-9d85-36e2e7dbc64f/targets/grpc%2Fjava%2Fv1.57.x%2Fbranch%2Fxds_k8s_lb%2Fround_robin_test/log

This has already been reported in #2024, but since then OpenApi generator released the fix in v6.4.0.

What you expected to happen:
No deprecation warnings logged.

How to reproduce it (as minimally and precisely as possible):
The warning is shown when kubernetes library is used within the unittest context, which enables all warnings per

Developers of test runners for Python code are advised to instead ensure that all warnings are displayed by default for the code under test
— https://docs.python.org/3/library/warnings.html#overriding-the-default-filter

I'm not entirely sure in what exact cases this warning is produced, but it's easy to verify when it's fixed.

Check the generated code RESTResponse.getheaders():

def getheaders(self):
"""Returns a dictionary of the response headers."""
return self.urllib3_response.getheaders()

This should be replaced with

    def getheaders(self):
        """Returns a dictionary of the response headers."""
        return self.urllib3_response.headers

Environment:

Kubernetes version

kubectl version:

Client Version: version.Info{Major:"1", Minor:"25+", GitVersion:"v1.25.9-dispatcher", GitCommit:"6ed97cc2601c54f907320513513db38e446aa2ee", GitTreeState:"clean", BuildDate:"2023-05-09T18:05:38Z", GoVersion:"go1.19.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.10-gke.1200", GitCommit:"9e9cdb04efcc29a8fe0b1804cdcc8054b9ee176a", GitTreeState:"clean", BuildDate:"2023-06-01T19:57:47Z", GoVersion:"go1.19.9 X:boringcrypto", Compiler:"gc", Platform:"linux/amd64"}
Python client version

The latest kubernetes==27.2.0 is affected.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Aug 8, 2023
  2. roycaihw commented on Aug 30, 2023

    @roycaihw
    Member

    We need to upgrade the openapi generator to pick up the fix. There has been someone working on it but it hasn't landed yet.

  3. k8s-triage-robot commented on Jan 27, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  4. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jan 27, 2024
  5. sergiitk commented on Feb 24, 2024

    @sergiitk
    Author

    /remove-lifecycle stale

  6. removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Feb 24, 2024
  7. k8s-triage-robot commented on May 24, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  8. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on May 24, 2024
  9. k8s-triage-robot commented on Jun 23, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle rotten
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  10. added
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jun 23, 2024
  11. k8s-triage-robot commented on Jul 23, 2024

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

  12. k8s-ci-robot commented on Jul 23, 2024

    @k8s-ci-robot
    Contributor

    @k8s-triage-robot: Closing this issue, marking it as "Not Planned".

    Details

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    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.

  13. varuzam commented on Aug 9, 2024

    @varuzam

    /reopen The latest kubernetes==30.1.0 is still affected.

  14. yliaog commented on Aug 14, 2024

    @yliaog
    Contributor

    /help

  15. k8s-ci-robot commented on Aug 14, 2024

    @k8s-ci-robot
    Contributor

    @yliaog:
    This request has been marked as needing help from a contributor.

    Guidelines

    Please ensure that the issue body includes answers to the following questions:

    • Why are we solving this issue?
    • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
    • Does this issue have zero to low barrier of entry?
    • How can the assignee reach out to you for help?

    For more details on the requirements of such an issue, please see here and ensure that they are met.

    If this request no longer meets these requirements, the label can be removed
    by commenting with the /remove-help command.

    Details

    In response to this:

    /help

    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.

  16. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Aug 14, 2024
  17. removed
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    on Aug 14, 2024
  18. sinux-l5d commented on Sep 4, 2024

    @sinux-l5d

    Hello,

    I'd like to help upgrading openapi-generator to v7.8.0. They added socks5h socket support on v7.2.0 in OpenAPITools/openapi-generator#16918 which would solve #1064.

    So far, I've only put v7.8.0 in scripts/update-client.sh and ran the script, see the result at sinux-l5d@9e3a354.
    But I can't run the test via unittest, even with a minikube cluster and all dependencies installed (including pydantic, which was required but not listed), so I guess I missed something. How does one usually run the tests suite?

    Reading the contributing file, I also understand that I will have to sign the CLA, which I'll of course do before opening a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions