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

pod_exec() yields inconsistent results

Abierto
#2,328 5 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
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
kubernetes, python
Área
api

Línea de trabajo

Comienza con examples/pod_exec.py, especialmente con la llamada de stream que usa connect_get_namespaced_pod_exec y run_forever(), y luego reproduce el comando repetidamente con las versiones indicadas de Kubernetes y del cliente. Traza cómo el stream informa del estado y returncode de channel 3; se considera terminado cuando un comando fallido informa de forma consistente del estado NonZeroExit en lugar de alternar entre éxito y fallo.

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

I'm trying to implement this code sample: https://github.com/kubernetes-client/python/blob/master/examples/pod_exec.py#L69-L82

But running multiple times the same command returns different results.

What you expected to happen:

I'm expecting all command execution to return the same result

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

Create a test.py

from kubernetes import client, config
from kubernetes.stream import stream

config.load_kube_config()
r = stream(client.CoreV1Api().connect_get_namespaced_pod_exec, name='mypod', namespace='default',
           container='mgmt', command=['false'], stderr=True, stdin=False, stdout=True, tty=False,
           _preload_content=False)

r.run_forever()
print(vars(r))
print(r.returncode)

Run it multiple times:

$ for i in {1..10}; do python test.py; sleep 2; done
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x103325840>, 'sock': <websocket._core.WebSocket object at 0x103364d70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x105c89840>, 'sock': <websocket._core.WebSocket object at 0x105cc8d70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x104ead840>, 'sock': <websocket._core.WebSocket object at 0x104eecd70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x103115840>, 'sock': <websocket._core.WebSocket object at 0x103154d70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x1079cd840>, 'sock': <websocket._core.WebSocket object at 0x107a0cd70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"command terminated with non-zero exit code: command terminated with exit code 1","reason":"NonZeroExitCode","details":{"causes":[{"reason":"ExitCode","message":"1"}]}}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x105019840>, 'sock': <websocket._core.WebSocket object at 0x105058d70>, '_returncode': None}
1
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x10742d840>, 'sock': <websocket._core.WebSocket object at 0x107468d70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x105dcd840>, 'sock': <websocket._core.WebSocket object at 0x105e08d70>, '_returncode': None}
0
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"command terminated with non-zero exit code: command terminated with exit code 1","reason":"NonZeroExitCode","details":{"causes":[{"reason":"ExitCode","message":"1"}]}}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x105ae5840>, 'sock': <websocket._core.WebSocket object at 0x105b24d70>, '_returncode': None}
1
{'_connected': False, '_channels': {3: '{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Success"}\n'}, 'binary': False, 'newline': '\n', '_all': <_io.StringIO object at 0x1076a5840>, 'sock': <websocket._core.WebSocket object at 0x1076e4d70>, '_returncode': None}
0

All those runs should return a NonZeroExit status.

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version): Client Version: v1.28.13
    Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
    Server Version: v1.29.11
  • OS (e.g., MacOS 10.13.6): MacOS Sequoia 15.2
  • Python version (python --version): Python 3.13.1
  • Python client version (pip list | grep kubernetes): kubernetes 31.0.0
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.