Skip to content

Commit

Permalink
Stephane/fast error message on docker creation (#32374)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-airbyte authored Nov 9, 2023
1 parent e7a1972 commit 08a8757
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ private ContainerFactory(String imageNamePlusMethods) {
private synchronized PostgreSQLContainer<?> getOrCreateSharedContainer() {
if (sharedContainer == null) {
if (containerCreationError != null) {
throw new RuntimeException("Error during container creation for imageName=" + imageName + ", methods=" + methods, containerCreationError);
throw new RuntimeException(
"Error during container creation for imageName=" + imageName + ", methods=" + methods.stream().map(Method::getName).toList(),
containerCreationError);
}
LOGGER.info("Creating new shared container based on {} with {}.", imageName, methods.stream().map(Method::getName).toList());
try {
final var parsed = DockerImageName.parse(imageName).asCompatibleSubstituteFor("postgres");
PostgreSQLContainer<?> sharedContainer = new PostgreSQLContainer<>(parsed);
sharedContainer = new PostgreSQLContainer<>(parsed);
for (Method method : methods) {
LOGGER.info("Calling {} on new shared container based on {}.", method.getName(),
imageName);
Expand All @@ -199,12 +201,13 @@ private synchronized PostgreSQLContainer<?> getOrCreateSharedContainer() {
sharedContainer.start();
} catch (IllegalAccessException | InvocationTargetException e) {
containerCreationError = new RuntimeException(e);
this.sharedContainer = null;
throw containerCreationError;
} catch (RuntimeException e) {
this.sharedContainer = null;
containerCreationError = e;
throw e;
}
this.sharedContainer = sharedContainer;
}
return sharedContainer;
}
Expand Down

0 comments on commit 08a8757

Please sign in to comment.