Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#2,101 11 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
kubernetes, python
Área
api, backend

Línea de trabajo

El código generado afectado se encuentra en kubernetes/client/rest.py, específicamente en RESTResponse.getheaders(); compáralo con la plantilla rest.mustache de v6.4.0 y encuentra el punto de entrada del repositorio para la regeneración o la actualización de dependencias. Regenera o actualiza el cliente con openapi-generator v6.4.0 o posterior, después ejecuta la suite de unittest correspondiente con las advertencias habilitadas y confirma que la advertencia de deprecación ha desaparecido.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

help wanted kind/bug

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():

https://github.com/kubernetes-client/python/blob/76ec6f5ce5572f66d82717e296480dc42584f0b7/kubernetes/client/rest.py#L42-L45

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.

Lenguaje dominante
Python
Estrellas
7.7k
Forks
3.5k
Merge medio
2 d 5 h
PR fusionados (30 d)
24

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kubernetes-client/python

Todos los issues de kubernetes-client/python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.