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

Add small delay in while loop to avoid spamming logs (ResourceReaper) #2287

Merged
merged 3 commits into from Feb 5, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions core/src/main/java/org/testcontainers/utility/ResourceReaper.java
Expand Up @@ -18,7 +18,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -137,6 +136,14 @@ public static String start(String hostIpAddress, DockerClient client) {
}
} catch (IOException e) {
log.warn("Can not connect to Ryuk at {}:{}", hostIpAddress, ryukPort, e);

try {
// sleep for a moment to avoid excessive log spam
Thread.sleep(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have RateLimiter available on classpath, could you please consider using it instead?
Also, 500ms is rather long initial delay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, of course.

} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
throw new RuntimeException(interrupted);
}
}
}
},
Expand Down Expand Up @@ -341,12 +348,12 @@ public void unregisterNetwork(String identifier) {
public void unregisterContainer(String identifier) {
registeredContainers.remove(identifier);
}

public void registerImageForCleanup(String dockerImageName) {
setHook();
registeredImages.add(dockerImageName);
}

private void removeImage(String dockerImageName) {
LOGGER.trace("Removing image tagged {}", dockerImageName);
try {
Expand Down