testcontainers / testcontainers/testcontainers-java
RemoteDockerImage should fail immediately on fatal errors, ability to specify a custom pull retry timeout
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
Right now RemoteDockerImage will try to re-pull container image on error until the default timeout of 2 minutes has been reached.
This is a reasonable thing to do to work around various I/O and network issues, but we should still allow user to specify a custom timeout and update the code to fail immediately on fatal errors (e.g. credential helper not available or invalid credentials configured).
Background, Context
If you utilize Docker image from some private registry (e.g. ECR, DockerHub, Quay, etc.) and credential helper for that registry is not available or credentials configured correctly, that could will try to retry up to 2 minutes before failing.
Exception similar to this one will be visible in the logs:
2021-02-23T12:34:35.050+0100 [DEBUG] [TestEventLogger] at java.base/java.lang.Thread.run(Thread.java:834)
2021-02-23T12:34:35.051+0100 [DEBUG] [TestEventLogger] [Test worker] WARN 🐳 [fooo.dkr.ecr.us-east-1.amazonaws.com/ingestion-pipeline:local-redis-cluster] - Retrying pull for image: foo.dkr.ecr.us-east-1.amazonaws.com/bar:foo (112s remaining)
2021-02-23T12:34:35.530+0100 [DEBUG] [TestEventLogger] [docker-java-stream--1357434991] ERROR com.github.dockerjava.api.async.ResultCallbackTemplate - Error during callback
2021-02-23T12:34:35.530+0100 [DEBUG] [TestEventLogger] com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"Get \"https://foo.dkr.ecr.us-east-1.amazonaws.com/v2/bar/foo\": no basic auth credentials"}
Proposed Change
I proposed updating that code to fail immediately if no basic auth credentials message is returned (https://github.com/Kami/testcontainers-java/blob/master/core/src/main/java/org/testcontainers/images/RemoteDockerImage.java#L87). I know that checking the error message is not the most robust thing, but it's probably the best we can do here.
Technically, Docker Java client could also be updated to throw some more specific exception in that case, but that would require more work.
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 core/src/main/java/org/testcontainers/images/RemoteDockerImage.java, in particolare dalla logica di retry intorno alla riga 87 indicata, e segui il modo in cui vengono restituiti gli errori di Docker pull. Il lavoro è completato quando i chiamanti possono fornire un timeout di retry del pull personalizzato e gli errori fatali delle credenziali come “no basic auth credentials” falliscono senza attendere il timeout predefinito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, java
- Ambito
- devops
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100