@Override public void up() throws IOException, InterruptedException { for (int currRetryAttempt = 0; currRetryAttempt <= retryAttempts; currRetryAttempt++) { try { getDockerCompose().up(); return; } catch (DockerExecutionException e) { Set<String> conflictingContainerNames = getConflictingContainerNames(e.getMessage()); if (conflictingContainerNames.isEmpty()) { // failed due to reason other than conflicting containers, so re-throw throw e; } log.debug("docker-compose up failed due to container name conflicts (container names: {}). " + "Removing containers and attempting docker-compose up again (attempt {}).", conflictingContainerNames, currRetryAttempt + 1); removeContainers(conflictingContainerNames); } } throw new DockerExecutionException("docker-compose up failed"); }
@Override public void up() throws IOException, InterruptedException { for (int currRetryAttempt = 0; currRetryAttempt <= retryAttempts; currRetryAttempt++) { try { getDockerCompose().up(); return; } catch (DockerExecutionException e) { Set<String> conflictingContainerNames = getConflictingContainerNames(e.getMessage()); if (conflictingContainerNames.isEmpty()) { // failed due to reason other than conflicting containers, so re-throw throw e; } log.debug("docker-compose up failed due to container name conflicts (container names: {}). " + "Removing containers and attempting docker-compose up again (attempt {}).", conflictingContainerNames, currRetryAttempt + 1); removeContainers(conflictingContainerNames); } } throw new DockerExecutionException("docker-compose up failed"); }
@Override public void up() throws IOException, InterruptedException { for (int currRetryAttempt = 0; currRetryAttempt <= retryAttempts; currRetryAttempt++) { try { getDockerCompose().up(); return; } catch (DockerExecutionException e) { Set<String> conflictingContainerNames = getConflictingContainerNames(e.getMessage()); if (conflictingContainerNames.isEmpty()) { // failed due to reason other than conflicting containers, so re-throw throw e; } log.debug("docker-compose up failed due to container name conflicts (container names: {}). " + "Removing containers and attempting docker-compose up again (attempt {}).", conflictingContainerNames, currRetryAttempt + 1); removeContainers(conflictingContainerNames); } } throw new DockerExecutionException("docker-compose up failed"); }
@Test public void parse_container_names_from_error_message_since_v13() { String conflictingContainer = "conflictingContainer"; ConflictingContainerRemovingDockerCompose conflictingContainerRemovingDockerCompose = new ConflictingContainerRemovingDockerCompose(dockerCompose, docker); Set<String> conflictingContainerNames = conflictingContainerRemovingDockerCompose .getConflictingContainerNames("The container name \"" + conflictingContainer + "\" is already in use"); assertEquals(ImmutableSet.of(conflictingContainer), conflictingContainerNames); }
@Test public void parse_container_names_from_error_message() { String conflictingContainer = "conflictingContainer"; ConflictingContainerRemovingDockerCompose conflictingContainerRemovingDockerCompose = new ConflictingContainerRemovingDockerCompose(dockerCompose, docker); Set<String> conflictingContainerNames = conflictingContainerRemovingDockerCompose .getConflictingContainerNames("The name \"" + conflictingContainer + "\" is already in use"); assertEquals(ImmutableSet.of(conflictingContainer), conflictingContainerNames); }