-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry failed calls to MappedPort to workaround inspect problem #2479
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up, I'm going to evaluate the impact of this change in the case there are multiple calls to the inspect method, as I'm suspicious it's not caching the response properly.
Other than that, LGTM, thanks!
Thanks @mdelapenya, this worked locally for me and I can reproduce it fairly consistently if you want me to change anything. The backoff isn't necessary if you'd like me to make the retries instant instead. |
As you can reproduce it fairly consistently, could you expand on this? I can now talk to the Docker folks regarding this and share this feedback 🙏 |
Sure thing, my setup is fairly straightforward:
With the opts exposing the port (:4242) and adding the appropriate wait strategies:
Now when I modify
I occasionally get the error message:
Where sometimes the external port is available |
Mmmm those logs makes me think the inspect is not caching the calls 🤔 let me take a look on that |
By the way @tylfin could you share your docker info? I'd like to understand if you are on Podman, Docker or any other container runtime. |
Sure thing, I'm using docker-for-mac on an M1 laptop, |
I was finally able to create a minimal reproduction, and realized this lifecycle hook is the cause:
When I switched it to |
I don't think the |
Exactly, the PostReadies happens right after the wait strategies, which is more consistent regarding availability of the service. The PostStarts hook does not guarantee the readiness, just that the container started. |
Alright, I'm going to go ahead and close this |
What does this PR do?
Add a retry loop to the
MappedPort
call in the docker package.Why is it important?
After some investigation into #605, it looks like Docker will sometimes return information from
inspectContainer
that doesn't include theNetworkSettings
. This makes requests toGenericContainer
fail intermittently.Related issues