testcontainers / testcontainers/testcontainers-python
Feature: Ryuk support in ComposeContainer class (like in Java)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2.3k
- Fork
- 386
- Merge medio
- 4h 40m
- PR unite (30g)
- 1
Descrizione
What are you trying to do?
When using testcontainers for Python in a CI/CD environment containers started using the ComposeContainer class are not stopped in crash or force-stop scenarios. The same class in Java cleaned up the started Containers via Ryuk.
It would be nice if the Python class ComposeContainer provides the same functionality of cleaning up the containers it started in a safe manner. (for example with Ryuk)
Safe cleanup of containers seems to be a core feature of the other *Container classes and is missing for compose files using the ComposeContainer class.
Here is a brief summary of how it is implemented in Java and potential changes:
ComposeContainer class in Java:
In the "start()" method "registerContainersForShutdown" is called. See:
In "registerContainersForShutdown"
the line ".registerLabelsFilterForCleanup(Collections.singletonMap("com.docker.compose.project", project));" effectivly adds a label filter to Ryuk using the official Docker property com.docker.compose.project with a random project ID. (see constructor of ComposeDelegate for "project" property)
Python doesn't have this functionality, see https://github.com/testcontainers/testcontainers-python/blob/a3476488ac1f7526a9c22d65251c8639d7089326/src/testcontainers/compose/compose.py#L84 for the analog of the ComposeContainer class in Python and https://github.com/testcontainers/testcontainers-python/blob/a3476488ac1f7526a9c22d65251c8639d7089326/src/testcontainers/compose/compose.py#L318 for the "start()" method that has no code to interact with Ryuk.
Why should it be done this way?
Please provide the same or similar functionality to allow safe usage of ComposeContainer class like in Java.
Thank you.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da src/testcontainers/compose/compose.py, in particolare dalla classe ComposeContainer intorno al metodo start() indicato, e confrontala con le implementazioni collegate di Java ComposeContainer e ComposeDelegate. Esamina le API esistenti per la registrazione di Python Ryuk prima di decidere come debbano essere registrate le label dei progetti Compose. Il lavoro è completato quando i container avviati da ComposeContainer vengono ripuliti in modo sicuro dopo arresti anomali o arresti forzati, con una copertura pertinente di questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, docker-compose, python
- Ambito
- devops, testing-qa
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 68/100