Skip to content
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

Show port mappings in HttpWaitStrategy #2341

Merged
merged 5 commits into from
Feb 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,20 @@ protected void waitUntilReady() {
if (null == livenessCheckPort || -1 == livenessCheckPort) {
return;
}
final String uri = buildLivenessUri(livenessCheckPort).toString();
log.info("{}: Waiting for {} seconds for URL: {}", containerName, startupTimeout.getSeconds(), uri);
final URI rawUri = buildLivenessUri(livenessCheckPort);
final String uri = rawUri.toString();

try {
// Un-map the port for logging
int originalPort = waitStrategyTarget.getExposedPorts().stream()
.filter(exposedPort -> rawUri.getPort() == waitStrategyTarget.getMappedPort(exposedPort))
.findFirst()
.orElseThrow(() -> new IllegalStateException("Target port " + rawUri.getPort() + " is not exposed"));
log.info("{}: Waiting for {} seconds for URL: {} (where port {} maps to container port {})", containerName, startupTimeout.getSeconds(), uri, rawUri.getPort(), originalPort);
} catch (RuntimeException e) {
// do not allow a failure in logging to prevent progress, but log for diagnosis
log.warn("Unexpected error occurred - will proceed to try to wait anyway", e);
}

// try to connect to the URL
try {
Expand Down Expand Up @@ -231,7 +243,7 @@ private URI buildLivenessUri(int livenessCheckPort) {
if ((tlsEnabled && 443 == livenessCheckPort) || (!tlsEnabled && 80 == livenessCheckPort)) {
portSuffix = "";
} else {
portSuffix = ":" + String.valueOf(livenessCheckPort);
portSuffix = ":" + livenessCheckPort;
}

return URI.create(scheme + host + portSuffix + path);
Expand Down