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

Shorten fallback to another strategy #4386

Merged
merged 6 commits into from
Sep 1, 2021
Merged

Conversation

pioorg
Copy link
Contributor

@pioorg pioorg commented Aug 20, 2021

It's about two things:

  • eliminating the re-try of Docker client strategy if it was chosen based on the configuration and failed with the first try (so no need/point to check that again)
  • shortening the "ping" timeout

Piotr added 2 commits August 20, 2021 10:20
When a strategy chosen based on the configuration failed, there should be no point in checking it again based on the list of all available strategies.
@@ -136,6 +136,7 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie
.peek(strategy -> log.info("Loaded {} from ~/.testcontainers.properties, will try it first", strategy.getClass().getName())),
strategies
.stream()
.filter(c -> !c.getClass().getCanonicalName().equals(TestcontainersConfiguration.getInstance().getDockerClientStrategyClassName()))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.filter(c -> !c.getClass().getCanonicalName().equals(TestcontainersConfiguration.getInstance().getDockerClientStrategyClassName()))
.filter(it -> !it.getClass().getCanonicalName().equals(TestcontainersConfiguration.getInstance().getDockerClientStrategyClassName()))

Copy link
Member

@bsideup bsideup Aug 20, 2021

Choose a reason for hiding this comment

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

Also, please extract TestcontainersConfiguration.getInstance().getDockerClientStrategyClassName() variable - used in two places (see Stream.of)

@@ -145,7 +146,7 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie

Info info;
try {
info = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, () -> {
info = Unreliables.retryUntilSuccess(5, TimeUnit.SECONDS, () -> {
Copy link
Contributor

@artjomka artjomka Aug 20, 2021

Choose a reason for hiding this comment

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

nit: maybe it would be worth it to extract that value as configuration property?
@bsideup @kiview @rnorth whats your view on that ?

Copy link
Member

Choose a reason for hiding this comment

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

This may not be a bad idea, actually 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, besides making the default timeout much shorter, we could also make it configurable (again)? So for people who need different TO (due to whatever reason) the would be an option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants