private void removeContainers(Collection<String> containerNames) throws IOException, InterruptedException { try { docker.rm(containerNames); } catch (DockerExecutionException e) { // there are cases such as in CircleCI where 'docker rm' returns a non-0 exit code and "fails", // but container is still effectively removed as far as conflict resolution is concerned. Because // of this, be permissive and do not fail task even if 'rm' fails. log.debug("docker rm failed, but continuing execution", e); } }
private void removeContainers(Collection<String> containerNames) throws IOException, InterruptedException { try { docker.rm(containerNames); } catch (DockerExecutionException e) { // there are cases such as in CircleCI where 'docker rm' returns a non-0 exit code and "fails", // but container is still effectively removed as far as conflict resolution is concerned. Because // of this, be permissive and do not fail task even if 'rm' fails. log.debug("docker rm failed, but continuing execution", e); } }
private void removeContainers(Collection<String> containerNames) throws IOException, InterruptedException { try { docker.rm(containerNames); } catch (DockerExecutionException e) { // there are cases such as in CircleCI where 'docker rm' returns a non-0 exit code and "fails", // but container is still effectively removed as far as conflict resolution is concerned. Because // of this, be permissive and do not fail task even if 'rm' fails. log.debug("docker rm failed, but continuing execution", e); } }
public void rm(Collection<String> containerNames) throws IOException, InterruptedException { rm(containerNames.toArray(new String[containerNames.size()])); }
public void rm(Collection<String> containerNames) throws IOException, InterruptedException { rm(containerNames.toArray(new String[containerNames.size()])); }
public void rm(Collection<String> containerNames) throws IOException, InterruptedException { rm(containerNames.toArray(new String[containerNames.size()])); }
private static void removeContainers(Docker docker, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); docker.rm(rawContainerNames); log.debug("Finished shutdown"); }
private static void removeContainers(Docker docker, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); docker.rm(rawContainerNames); log.debug("Finished shutdown"); }
private static void removeContainers(Docker docker, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); docker.rm(rawContainerNames); log.debug("Finished shutdown"); }
private static void removeContainers(Docker docker, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); docker.rm(rawContainerNames); log.debug("Finished shutdown"); }
private void removeContainers(DockerComposeRule rule, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); rule.docker().rm(rawContainerNames); log.debug("Finished shutdown"); }
private void removeContainers(DockerComposeRule rule, List<ContainerName> running) throws IOException, InterruptedException { List<String> rawContainerNames = running.stream() .map(ContainerName::rawName) .collect(toList()); rule.docker().rm(rawContainerNames); log.debug("Finished shutdown"); }
@Test public void call_docker_rm_with_force_flag_on_rm() throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("")); docker.rm("testContainer"); verify(executor).execute("rm", "-f", "testContainer"); }
@Test public void first_btrfs_error_should_be_caught_silently_and_retried() throws Exception { doThrow(new DockerExecutionException(btrfs_message)) .doNothing() .when(mockDocker) .rm(anyListOf(String.class)); ShutdownStrategy.AGGRESSIVE.shutdown(mockDockerCompose, mockDocker); verify(mockDocker, times(2)).rm(anyListOf(String.class)); }
@Test public void ignore_docker_execution_exceptions_in_rm() throws IOException, InterruptedException { String conflictingContainer = "conflictingContainer"; doThrow(new DockerExecutionException("The name \"" + conflictingContainer + "\" is already in use")) .doNothing() .when(dockerCompose).up(); doThrow(DockerExecutionException.class).when(docker).rm(anySetOf(String.class)); ConflictingContainerRemovingDockerCompose conflictingContainerRemovingDockerCompose = new ConflictingContainerRemovingDockerCompose(dockerCompose, docker); conflictingContainerRemovingDockerCompose.up(); verify(dockerCompose, times(2)).up(); verify(docker).rm(ImmutableSet.of(conflictingContainer)); }
@Test public void after_two_btrfs_failures_we_should_just_log_and_continue() throws Exception { doThrow(new DockerExecutionException(btrfs_message)) .doThrow(new DockerExecutionException(btrfs_message)) .when(mockDocker) .rm(anyListOf(String.class)); ShutdownStrategy.AGGRESSIVE.shutdown(mockDockerCompose, mockDocker); verify(mockDocker, times(2)).rm(anyListOf(String.class)); }
@Test public void docker_compose_down_should_be_called_despite_docker_rm_throwing_exception() throws Exception { doThrow(new DockerExecutionException(error_msg)) .when(mockDocker) .rm(anyListOf(String.class)); ShutdownStrategy.AGGRESSIVE_WITH_NETWORK_CLEANUP.shutdown(mockDockerCompose, mockDocker); verify(mockDockerCompose, times(1)).down(); }
@Test public void call_rm_and_retry_up_if_conflicting_containers_exist() throws IOException, InterruptedException { String conflictingContainer = "conflictingContainer"; doThrow(new DockerExecutionException("The name \"" + conflictingContainer + "\" is already in use")) .doNothing() .when(dockerCompose).up(); ConflictingContainerRemovingDockerCompose conflictingContainerRemovingDockerCompose = new ConflictingContainerRemovingDockerCompose(dockerCompose, docker); conflictingContainerRemovingDockerCompose.up(); verify(dockerCompose, times(2)).up(); verify(docker).rm(ImmutableSet.of(conflictingContainer)); }
@Test public void before_retries_when_docker_up_reports_conflicting_containers() throws IOException, InterruptedException { String conflictingContainer = "conflictingContainer"; doThrow(new DockerExecutionException("The name \"" + conflictingContainer + "\" is already in use")) .doNothing() .when(dockerCompose).up(); rule = defaultBuilder().docker(mockDocker).build(); rule.before(); verify(dockerCompose, times(2)).up(); verify(mockDocker).rm(ImmutableSet.of(conflictingContainer)); }
@Test public void fail_on_non_docker_execution_exceptions_in_rm() throws IOException, InterruptedException { String conflictingContainer = "conflictingContainer"; doThrow(new DockerExecutionException("The name \"" + conflictingContainer + "\" is already in use")) .doNothing() .when(dockerCompose).up(); doThrow(RuntimeException.class).when(docker).rm(anySetOf(String.class)); exception.expect(RuntimeException.class); ConflictingContainerRemovingDockerCompose conflictingContainerRemovingDockerCompose = new ConflictingContainerRemovingDockerCompose(dockerCompose, docker); conflictingContainerRemovingDockerCompose.up(); }