-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 internal port checking in the same exec #4460
Conversation
...main/java/org/testcontainers/containers/wait/internal/InternalCommandPortListeningCheck.java
Outdated
Show resolved
Hide resolved
|
||
for (int internalPort : internalPorts) { | ||
command.append(" && "); | ||
command.append(" ("); | ||
command.append(format("cat /proc/net/tcp* | awk '{print $2}' | grep -i ':0*%x'", internalPort)); | ||
command.append(format("grep -i ':0*%x' /proc/net/tcp*", internalPort)); |
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.
minus dependencies on cat
and awk
, just in case :)
LGTM Lines 44 to 45 in 672cbee
Wouldn't this mean that a failing external check would still lead to unnecessary exec calls? At least it does not hurt for now and keeps the PR small. |
@kiview one additional benefit of still having Unreliables there is to timeout (which will lead to container startup failure and the container being removed, so exec will eventually be terminated) |
Makes total sense. Let me just try with Kafka, to see if there is an observable difference. |
@kiview I thought about it (and already have a prepared follow up for caching the results) 👍 Will do right after this one :) |
Cool, just FYI, my naive experiment of Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS,
() -> getRateLimiter().getWhenReady(internalCheck));
Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS,
() -> getRateLimiter().getWhenReady(externalCheck)); made in 1s slower 😱 |
Oh this is fun; on Mac/Win the external check will possibly pass before the internal check (because of the userland proxy racing the real process). On Linux, if one passes the other really should be a no-op. This gets weird to reason about if I've deleted my thinking, but wrote more about this. TLDR is that I think we could overthink this, so let's just be guided by the numbers of what works quickly and what's easy to read 😂 |
@rnorth yep, exactly the reason why we perform both :D The hidden gems of Testcontainers :D |
Exec'ing with Docker is slow. Even if the command itself takes 10ms to execute,
docker exec
would take 300ms or so. This PR addswhile true
-style waiting in the sameexec
session, so that we pay the overhead ofexec
only once.Before:
After: