diff --git a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/configuration/ShutdownStrategy.java b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/configuration/ShutdownStrategy.java index 9c5f44c979..6c5bce4c13 100644 --- a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/configuration/ShutdownStrategy.java +++ b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/configuration/ShutdownStrategy.java @@ -17,8 +17,6 @@ import java.io.IOException; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.AggressiveShutdownStrategy; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.AggressiveShutdownWithNetworkCleanupStrategy; import org.springframework.cloud.dataflow.common.test.docker.compose.execution.Docker; import org.springframework.cloud.dataflow.common.test.docker.compose.execution.DockerCompose; import org.springframework.cloud.dataflow.common.test.docker.compose.execution.GracefulShutdownStrategy; @@ -31,20 +29,6 @@ */ public interface ShutdownStrategy { - /** - * Call rm on all containers, working around btrfs bug on CircleCI. - * - * @deprecated Use {@link #KILL_DOWN} (the default strategy) - */ - @Deprecated - ShutdownStrategy AGGRESSIVE = new AggressiveShutdownStrategy(); - /** - * Call rm on all containers, then call docker-compose down. - * - * @deprecated Use {@link #KILL_DOWN} (the default strategy) - */ - @Deprecated - ShutdownStrategy AGGRESSIVE_WITH_NETWORK_CLEANUP = new AggressiveShutdownWithNetworkCleanupStrategy(); /** * Call docker-compose down, kill, then rm. Allows containers up to 10 seconds to shut down * gracefully. diff --git a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownStrategy.java b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownStrategy.java deleted file mode 100644 index 293561fade..0000000000 --- a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownStrategy.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2018-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.cloud.dataflow.common.test.docker.compose.execution; - -import java.io.IOException; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.cloud.dataflow.common.test.docker.compose.configuration.ShutdownStrategy; -import org.springframework.cloud.dataflow.common.test.docker.compose.connection.ContainerName; - -import static java.util.stream.Collectors.toList; - -/** - * Shuts down containers as fast as possible, without giving them time to finish - * IO or clean up any resources. - * - * @deprecated Use {@link ShutdownStrategy#KILL_DOWN} - */ -@Deprecated -public class AggressiveShutdownStrategy implements ShutdownStrategy { - - private static final Logger log = LoggerFactory.getLogger(AggressiveShutdownStrategy.class); - - @Override - public void shutdown(DockerCompose dockerCompose, Docker docker) throws IOException, InterruptedException { - List runningContainers = dockerCompose.ps(); - - log.info("Shutting down {}", runningContainers.stream().map(ContainerName::semanticName).collect(toList())); - if (removeContainersCatchingErrors(docker, runningContainers)) { - return; - } - - log.debug("First shutdown attempted failed due to btrfs volume error... retrying"); - if (removeContainersCatchingErrors(docker, runningContainers)) { - return; - } - - log.warn("Couldn't shut down containers due to btrfs volume error, " - + "see https://circleci.com/docs/docker-btrfs-error/ for more info."); - - log.info("Pruning networks"); - docker.pruneNetworks(); - } - - private static boolean removeContainersCatchingErrors(Docker docker, List runningContainers) throws IOException, InterruptedException { - try { - removeContainers(docker, runningContainers); - return true; - } catch (DockerExecutionException exception) { - return false; - } - } - - private static void removeContainers(Docker docker, List running) throws IOException, InterruptedException { - List rawContainerNames = running.stream() - .map(ContainerName::rawName) - .collect(toList()); - - docker.rm(rawContainerNames); - log.debug("Finished shutdown"); - } - -} diff --git a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownWithNetworkCleanupStrategy.java b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownWithNetworkCleanupStrategy.java deleted file mode 100644 index b762fd5064..0000000000 --- a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/AggressiveShutdownWithNetworkCleanupStrategy.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.cloud.dataflow.common.test.docker.compose.execution; - -import java.io.IOException; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.cloud.dataflow.common.test.docker.compose.configuration.ShutdownStrategy; -import org.springframework.cloud.dataflow.common.test.docker.compose.connection.ContainerName; - -import static java.util.stream.Collectors.toList; - -/** - * Shuts down containers as fast as possible while cleaning up any networks that were created. - * - * @deprecated Use {@link ShutdownStrategy#KILL_DOWN} - */ -@Deprecated -public class AggressiveShutdownWithNetworkCleanupStrategy implements ShutdownStrategy { - - private static final Logger log = LoggerFactory.getLogger(AggressiveShutdownWithNetworkCleanupStrategy.class); - - @Override - public void shutdown(DockerCompose dockerCompose, Docker docker) throws IOException, InterruptedException { - List runningContainers = dockerCompose.ps(); - - log.info("Shutting down {}", runningContainers.stream().map(ContainerName::semanticName).collect(toList())); - removeContainersCatchingErrors(docker, runningContainers); - removeNetworks(dockerCompose, docker); - - } - - private static void removeContainersCatchingErrors(Docker docker, List runningContainers) throws IOException, InterruptedException { - try { - removeContainers(docker, runningContainers); - } catch (DockerExecutionException exception) { - log.error("Error while trying to remove containers: {}", exception.getMessage()); - } - } - - private static void removeContainers(Docker docker, List running) throws IOException, InterruptedException { - List rawContainerNames = running.stream() - .map(ContainerName::rawName) - .collect(toList()); - - docker.rm(rawContainerNames); - log.debug("Finished shutdown"); - } - - private static void removeNetworks(DockerCompose dockerCompose, Docker docker) throws IOException, InterruptedException { - dockerCompose.down(); - docker.pruneNetworks(); - } -} diff --git a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownStrategyTest.java b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownStrategyTest.java deleted file mode 100644 index a50b88835c..0000000000 --- a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownStrategyTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.cloud.dataflow.common.test.docker.compose; - -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Test; -import org.springframework.cloud.dataflow.common.test.docker.compose.configuration.ShutdownStrategy; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.Docker; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.DockerCompose; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.DockerExecutionException; - -public class AggressiveShutdownStrategyTest { - - private final DockerCompose mockDockerCompose = mock(DockerCompose.class); - private final Docker mockDocker = mock(Docker.class); - - private static final String btrfs_message = "'docker rm -f test-1.container.name test-2.container.name' " - + "returned exit code 1\nThe output was:\nFailed to remove container (test-1.container.name): " - + "Error response from daemon: Driver btrfs failed to remove root filesystem "; - - @Test - public void first_btrfs_error_should_be_caught_silently_and_retried() throws Exception { - doThrow(new DockerExecutionException(btrfs_message)) - .doNothing() - .when(mockDocker) - .rm(anyList()); - - ShutdownStrategy.AGGRESSIVE.shutdown(mockDockerCompose, mockDocker); - - verify(mockDocker, times(2)).rm(anyList()); - } - - @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(anyList()); - - ShutdownStrategy.AGGRESSIVE.shutdown(mockDockerCompose, mockDocker); - - verify(mockDocker, times(2)).rm(anyList()); - } - -} diff --git a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownWithNetworkCleanupStrategyTest.java b/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownWithNetworkCleanupStrategyTest.java deleted file mode 100644 index 5ad5037f7c..0000000000 --- a/spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/test/java/org/springframework/cloud/dataflow/common/test/docker/compose/AggressiveShutdownWithNetworkCleanupStrategyTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2018-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.cloud.dataflow.common.test.docker.compose; - -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Test; -import org.springframework.cloud.dataflow.common.test.docker.compose.configuration.ShutdownStrategy; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.Docker; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.DockerCompose; -import org.springframework.cloud.dataflow.common.test.docker.compose.execution.DockerExecutionException; - -public class AggressiveShutdownWithNetworkCleanupStrategyTest { - -// @Rule -// public final ExpectedException exception = ExpectedException.none(); - - private final DockerCompose mockDockerCompose = mock(DockerCompose.class); - private final Docker mockDocker = mock(Docker.class); - - private static final String error_msg = "Random DockerExecutionException message"; - - @Test - public void docker_compose_down_should_be_called_despite_docker_rm_throwing_exception() throws Exception { - doThrow(new DockerExecutionException(error_msg)) - .when(mockDocker) - .rm(anyList()); - - ShutdownStrategy.AGGRESSIVE_WITH_NETWORK_CLEANUP.shutdown(mockDockerCompose, mockDocker); - - verify(mockDockerCompose, times(1)).down(); - } - -} diff --git a/whats-new.adoc b/whats-new.adoc index 22377bf04f..536a56c1af 100644 --- a/whats-new.adoc +++ b/whats-new.adoc @@ -41,6 +41,7 @@ VersionInfoProperties versionInfoProperties, SecurityStateBean securityStateBean * The deprecated `rollback(String releaseName, int releaseVersion)` method in SkipperClient has been removed. Use `rollback(RollbackRequest rollbackRequest). * Removed the `DefaultTaskExecutionService` constructor that does not take the `composedTaskRunnerConfigurationProperties` parameter. Use the constructor that offers the `composedTaskRunnerConfigurationProperties` parameter. * * Removed the `DefaultTaskExecutionInfoService` constructor that does not take the `composedTaskRunnerConfigurationProperties` parameter. Use the constructor that offers the `composedTaskRunnerConfigurationProperties` parameter. -=== Breaking Changes +* AggressiveShutdownStrategy & AggressiveShutdownWithNetworkCleanupStrategy deprecated classes have been removed. Use the KillDownShutdownStrategy class. +== Breaking Changes Announce deprecated changes here