From df26691804e5f77164434edd668af1d00e24cd2b Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Wed, 16 Oct 2024 07:45:36 -0400 Subject: [PATCH] Allow users to disable task features in dataflow (#5971) Currently if the user sets task-enabled to false SCDF will fail to start. Rename DataflowTaskConfiguration to DataflowTaskExplorerConfiguration so that it expresses its usage. Rename aggregateTaskExplorer to dataflowTaskExplorer Set the `ConditionalOnTasksEnabled` annotation so that the configuration won't fire if `task-enabled` is set to false. Remove the `Disabled` annotation from the test so that we can verify that the `task-enabled` works properly. --- .../dataflow/server/config/DataFlowServerConfiguration.java | 4 ++-- .../dataflow/server/config/features/TaskConfiguration.java | 4 ++-- ...guration.java => DataflowTaskExplorerConfiguration.java} | 6 ++++-- .../dataflow/server/configuration/JobDependencies.java | 4 ++-- .../server/configuration/TaskServiceDependencies.java | 4 ++-- .../dataflow/server/configuration/TestDependencies.java | 4 ++-- .../dataflow/server/single/LocalConfigurationTests.java | 3 --- 7 files changed, 14 insertions(+), 15 deletions(-) rename spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/{DataflowTaskConfiguration.java => DataflowTaskExplorerConfiguration.java} (88%) diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowServerConfiguration.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowServerConfiguration.java index 431f33bebe..91c9699df7 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowServerConfiguration.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/DataFlowServerConfiguration.java @@ -31,7 +31,7 @@ import org.springframework.cloud.dataflow.server.config.web.WebConfiguration; import org.springframework.cloud.dataflow.server.db.migration.DataFlowFlywayConfigurationCustomizer; import org.springframework.cloud.dataflow.server.support.AuthenticationSuccessEventListener; -import org.springframework.cloud.dataflow.server.task.DataflowTaskConfiguration; +import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorerConfiguration; import org.springframework.cloud.task.configuration.TaskProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -64,7 +64,7 @@ FeaturesConfiguration.class, WebConfiguration.class, H2ServerConfiguration.class, - DataflowTaskConfiguration.class, + DataflowTaskExplorerConfiguration.class, DataFlowTaskConfiguration.class }) @EnableConfigurationProperties({ BatchProperties.class, CommonApplicationProperties.class }) diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/features/TaskConfiguration.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/features/TaskConfiguration.java index b93954b244..2b0fe0106a 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/features/TaskConfiguration.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/config/features/TaskConfiguration.java @@ -60,7 +60,7 @@ import org.springframework.cloud.dataflow.server.service.impl.DefaultTaskSaveService; import org.springframework.cloud.dataflow.server.service.impl.TaskAppDeploymentRequestCreator; import org.springframework.cloud.dataflow.server.service.impl.TaskConfigurationProperties; -import org.springframework.cloud.dataflow.server.task.DataflowTaskConfiguration; +import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorerConfiguration; import org.springframework.cloud.dataflow.server.task.DataflowTaskExecutionQueryDao; import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorer; import org.springframework.cloud.dataflow.server.task.TaskDefinitionReader; @@ -103,7 +103,7 @@ @EnableTransactionManagement @Import({ TaskConfiguration.TaskDeleteServiceConfig.class, - DataflowTaskConfiguration.class, + DataflowTaskExplorerConfiguration.class, DataFlowTaskConfiguration.class }) public class TaskConfiguration { diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskConfiguration.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskExplorerConfiguration.java similarity index 88% rename from spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskConfiguration.java rename to spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskExplorerConfiguration.java index 6a6972ae9e..e86511b7dd 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskConfiguration.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/task/DataflowTaskExplorerConfiguration.java @@ -17,6 +17,7 @@ import javax.sql.DataSource; +import org.springframework.cloud.dataflow.server.config.features.ConditionalOnTasksEnabled; import org.springframework.cloud.dataflow.server.task.impl.DefaultDataflowTaskExplorer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -27,11 +28,12 @@ * * @author Corneil du Plessis */ +@ConditionalOnTasksEnabled @Configuration -public class DataflowTaskConfiguration { +public class DataflowTaskExplorerConfiguration { @Bean - public DataflowTaskExplorer aggregateTaskExplorer( + public DataflowTaskExplorer dataflowTaskExplorer( DataSource dataSource, DataflowTaskExecutionQueryDao taskExecutionQueryDao, TaskDefinitionReader taskDefinitionReader, diff --git a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/JobDependencies.java b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/JobDependencies.java index 2734580279..3af2a3e696 100644 --- a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/JobDependencies.java +++ b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/JobDependencies.java @@ -100,7 +100,7 @@ import org.springframework.cloud.dataflow.server.service.impl.TaskAppDeploymentRequestCreator; import org.springframework.cloud.dataflow.server.service.impl.TaskConfigurationProperties; import org.springframework.cloud.dataflow.server.service.impl.validation.DefaultTaskValidationService; -import org.springframework.cloud.dataflow.server.task.DataflowTaskConfiguration; +import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorerConfiguration; import org.springframework.cloud.dataflow.server.task.DataflowTaskExecutionQueryDao; import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorer; import org.springframework.cloud.dataflow.server.task.impl.DefaultDataFlowTaskExecutionQueryDao; @@ -139,7 +139,7 @@ @Configuration @EnableSpringDataWebSupport @Import({ - DataflowTaskConfiguration.class, + DataflowTaskExplorerConfiguration.class, DataFlowTaskConfiguration.class }) @ImportAutoConfiguration({ diff --git a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TaskServiceDependencies.java b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TaskServiceDependencies.java index 2d0f79bbbd..aab6378109 100644 --- a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TaskServiceDependencies.java +++ b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TaskServiceDependencies.java @@ -80,7 +80,7 @@ import org.springframework.cloud.dataflow.server.service.impl.TaskAppDeploymentRequestCreator; import org.springframework.cloud.dataflow.server.service.impl.TaskConfigurationProperties; import org.springframework.cloud.dataflow.server.service.impl.validation.DefaultTaskValidationService; -import org.springframework.cloud.dataflow.server.task.DataflowTaskConfiguration; +import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorerConfiguration; import org.springframework.cloud.dataflow.server.task.DataflowTaskExecutionQueryDao; import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorer; import org.springframework.cloud.dataflow.server.task.impl.DefaultDataFlowTaskExecutionQueryDao; @@ -125,7 +125,7 @@ @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) @Import({ CompletionConfiguration.class, - DataflowTaskConfiguration.class, + DataflowTaskExplorerConfiguration.class, DataFlowTaskConfiguration.class }) @ImportAutoConfiguration({ diff --git a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TestDependencies.java b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TestDependencies.java index e097c3dc8f..dba23a53b7 100644 --- a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TestDependencies.java +++ b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/configuration/TestDependencies.java @@ -146,7 +146,7 @@ import org.springframework.cloud.dataflow.server.service.impl.validation.DefaultTaskValidationService; import org.springframework.cloud.dataflow.server.stream.SkipperStreamDeployer; import org.springframework.cloud.dataflow.server.stream.StreamDeployer; -import org.springframework.cloud.dataflow.server.task.DataflowTaskConfiguration; +import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorerConfiguration; import org.springframework.cloud.dataflow.server.task.DataflowTaskExecutionQueryDao; import org.springframework.cloud.dataflow.server.task.DataflowTaskExplorer; import org.springframework.cloud.dataflow.server.task.impl.DefaultDataFlowTaskExecutionQueryDao; @@ -204,7 +204,7 @@ @EnableSpringDataWebSupport @Import({ CompletionConfiguration.class, - DataflowTaskConfiguration.class, + DataflowTaskExplorerConfiguration.class, DataFlowTaskConfiguration.class, ContainerRegistryAutoConfiguration.class, TaskConfiguration.TaskJobServiceConfig.class diff --git a/spring-cloud-starter-dataflow-server/src/test/java/org/springframework/cloud/dataflow/server/single/LocalConfigurationTests.java b/spring-cloud-starter-dataflow-server/src/test/java/org/springframework/cloud/dataflow/server/single/LocalConfigurationTests.java index 13bf87263b..81073b08ae 100644 --- a/spring-cloud-starter-dataflow-server/src/test/java/org/springframework/cloud/dataflow/server/single/LocalConfigurationTests.java +++ b/spring-cloud-starter-dataflow-server/src/test/java/org/springframework/cloud/dataflow/server/single/LocalConfigurationTests.java @@ -19,7 +19,6 @@ import java.util.Map; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -104,8 +103,6 @@ void configWithStreamsDisabled() { } } - //TODO: Boot3x followup - @Disabled("TODO: Boot3x DataflowServerConfiguration requires DataflowTaskExecutionQueryDao bean. Doesn't seem like it is needed.") @Test void configWithTasksDisabled() { SpringApplication app = new SpringApplication(LocalTestDataFlowServer.class);