Bug: LogMessageWaitStrategy: a container that exits before its message raises without its logs, and __enter__ then removes the container
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
Línea de trabajo
Lee core/wait_strategies.py, especialmente LogMessageWaitStrategy.wait_until_ready y su ruta de timeout. Después, comprueba en core/container.py cómo DockerContainer.start gestiona las excepciones. Reproduce el problema con el comando de MongoDB proporcionado y compara el error de proceso terminado con el error de timeout. El trabajo estará completo cuando el mensaje de RuntimeError de la ruta de proceso terminado incluya el fragmento disponible de stdout y stderr.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: testcontainers 4.15.0 (Python). The same code is on main as read on 2026-10-20.
What happens. A container that exits before it logs the message a LogMessageWaitStrategy waits for raises:
RuntimeError: Container exited (status: exited, exit code: 1) before emitting logs containing 'waiting for connections'. Container error: . Hint: Check container logs and ensure the application is configured to start correctly. The application may be crashing or exiting early.
The hint says to check the container's logs, but there is no way to read them afterwards:
LogMessageWaitStrategy.wait_until_ready (core/wait_strategies.py) has the logs in hand when it notices the exit. It has just called container.get_logs() to search them. But the RuntimeError it raises carries only the status, the exit code and State.Error, which is the daemon's own error field and is empty when the process exits on its own. Its timeout path does include "Recent stdout" and "Recent stderr", while its exited path does not.
DockerContainer.start (core/container.py) attaches the logs as a note only on except TimeoutError, so the RuntimeError above passes through without them.
DockerContainer.enter catches any exception from start(), calls exit, which stops and removes the container with remove(force=True, v=True), and re-raises. By the time the error reaches the caller, the container and its logs are gone.
So a container that dies at start under with DockerContainer(...) as c: leaves nothing to diagnose it with. This is the case the hint is written for.
How we met it. mongod 8.3.13 refuses some host kernels at startup (SERVER-121912). It logs one fatal line and exits 1, and GitHub's ubuntu-24.04 runner image 20261018 carries such a kernel. Our CI showed only the message above, about 3,000 times, once per test. The cause became visible only after we started our containers without the context manager, read get_logs() in our own except and removed the container ourselves.
To reproduce:
from testcontainers.core.container import DockerContainer
from testcontainers.core.wait_strategies import LogMessageWaitStrategy
container = DockerContainer("mongo:8.3.13").with_command("--refusedAtStart")
container.waiting_for(LogMessageWaitStrategy("waiting for connections"))
with container:
pass
mongod refuses the unknown option, logs why and exits. The error names neither the option nor mongod's line.
Suggested fix. On the exited path, include the tail of the stdout and stderr the strategy already read, as the timeout path does. Because the message carries the log, a caller that only has str(error) gets it too: pytest-xdist workers, for example, receive only the string, so a note would be lost on the way.
- Lenguaje dominante
- Python
- Estrellas
- 2.3k
- Forks
- 395
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testcontainers/testcontainers-python
-
Bug: HttpWaitStrategy ignores response predicates for accepted HTTP error statusesPosiblemente ocupada @PranavMulakala la tomó hace 24 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
testcontainers/testcontainers-python#1143 ·
Los mantenedores suelen responder en 1 día
-
Updating the documentationAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
testcontainers/testcontainers-python#1086 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Bug: [minio] _healthcheck calls for nested wait_container_is_ready resulting in long wait timeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
testcontainers/testcontainers-python#578 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug: Reaper is force-removed at interpreter exit since 4.15.0, session containers are never reapedPosiblemente ocupada @pantafive la tomó hace 25 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
testcontainers/testcontainers-python#1140 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
testcontainers/testcontainers-python#1137 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
canonical/paas-charm#407 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
Los mantenedores suelen responder en 1 día
-
enhancement tooling
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
`read_nexus` entry point points to a function that no longer existsPosiblemente ocupada @RubelMozumder la tomó hoy. Abiertoannotator bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
FAIRmat-NFDI/pynxtools#876 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: HTTP 499 (Client Closed Request) is classified as a non-retryable format_error, so a mid-flight abort fails the turn over instead of retryingPosiblemente ocupada @yipinghuang1991 la tomó hoy. Abiertocomp/agent P2 type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NousResearch/hermes-agent#156837 ·
Los mantenedores suelen responder en 1 día