Skip to content

Commit

Permalink
fabric8io#970 postStart exec breakOnError should fail fast
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Praet <jimmy.praet@ksz-bcss.fgov.be>
  • Loading branch information
jpraet committed Mar 18, 2018
1 parent 689b7e0 commit 97bfc90
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/main/java/io/fabric8/maven/docker/StartMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,14 @@ public synchronized void executeInternal(final ServiceHub hub) throws DockerAcce
// Move from waiting to starting status
imagesStarting.add(image);
imagesWaitingToStart.remove(image);

if (!startParallel) {
waitForStartedContainer(hub, containerStartupService, startedContainerAliases, imagesStarting);
}
}

// Wait for the next container to finish startup
final Future<StartedContainer> startedContainerFuture = containerStartupService.take();
try {
final StartedContainer startedContainer = startedContainerFuture.get();
final ImageConfiguration imageConfig = startedContainer.imageConfig;

updateAliasesSet(startedContainerAliases, imageConfig.getAlias());
exposeContainerProps(hub.getQueryService(), startedContainer);

// All done with this image
imagesStarting.remove(imageConfig);
} catch (ExecutionException e) {
rethrowCause(e);
if (startParallel) {
waitForStartedContainer(hub, containerStartupService, startedContainerAliases, imagesStarting);
}
}

Expand Down Expand Up @@ -184,6 +177,26 @@ public synchronized void executeInternal(final ServiceHub hub) throws DockerAcce
}
}

private void waitForStartedContainer(final ServiceHub hub,
final ExecutorCompletionService<StartedContainer> containerStartupService,
final Set<String> startedContainerAliases, final Queue<ImageConfiguration> imagesStarting)
throws InterruptedException, DockerAccessException, IOException, ExecException {
// Wait for the next container to finish startup
final Future<StartedContainer> startedContainerFuture = containerStartupService.take();
try {
final StartedContainer startedContainer = startedContainerFuture.get();
final ImageConfiguration imageConfig = startedContainer.imageConfig;

updateAliasesSet(startedContainerAliases, imageConfig.getAlias());
exposeContainerProps(hub.getQueryService(), startedContainer);

// All done with this image
imagesStarting.remove(imageConfig);
} catch (ExecutionException e) {
rethrowCause(e);
}
}

protected Boolean followLogs() {
return Boolean.valueOf(System.getProperty("docker.follow", "false"));
}
Expand Down

0 comments on commit 97bfc90

Please sign in to comment.