Skip to content

Commit

Permalink
Address second round of PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nmiyake committed Jun 14, 2016
1 parent 5e20c6c commit 0b2e287
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public ConflictingContainerRemovingDockerCompose(DockerCompose dockerCompose, Do

@Override
public void up() throws IOException, InterruptedException {
int currRetryAttempt = 0;

while (true) {
for (int currRetryAttempt = 0; currRetryAttempt <= retryAttempts; currRetryAttempt++) {
try {
super.up();
getDockerCompose().up();
return;
} catch (DockerExecutionException e) {
Set<String> conflictingContainerNames = getConflictingContainerNames(e.getMessage());
Expand All @@ -59,16 +57,10 @@ public void up() throws IOException, InterruptedException {
throw e;
}

if (currRetryAttempt == retryAttempts) {
break;
}

log.debug("docker-compose up failed due to container name conflicts (container names: {}). "
+ "Removing containers and attempting docker-compose up again (attempt {}).",
+ "Removing containers and attempting docker-compose up again (attempt {}).",
conflictingContainerNames, currRetryAttempt + 1);
removeContainers(conflictingContainerNames);

currRetryAttempt++;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import java.io.IOException;
import java.io.OutputStream;

public abstract class DelegatingDockerCompose implements DockerCompose {
abstract class DelegatingDockerCompose implements DockerCompose {
private final DockerCompose dockerCompose;

public DelegatingDockerCompose(DockerCompose dockerCompose) {
protected DelegatingDockerCompose(DockerCompose dockerCompose) {
this.dockerCompose = dockerCompose;
}

Expand Down Expand Up @@ -78,4 +78,9 @@ public boolean writeLogs(String container, OutputStream output) throws IOExcepti
public Ports ports(String service) throws IOException, InterruptedException {
return dockerCompose.ports(service);
}

protected final DockerCompose getDockerCompose() {
return dockerCompose;
}

}

0 comments on commit 0b2e287

Please sign in to comment.