From de253dcb464b5a406cbf8aaa39a40234244f02f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 1 Jul 2024 18:59:54 +0000 Subject: [PATCH] Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors (#750) * Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors Signed-off-by: Craig Perkins * Add CHANGELOG entry Signed-off-by: Craig Perkins * Remove extra characters Signed-off-by: Craig Perkins * Address code review comments Signed-off-by: Craig Perkins --------- Signed-off-by: Craig Perkins (cherry picked from commit cf1016fd72e0f9196db498cbb52f4a57bafadade) Signed-off-by: github-actions[bot] --- CHANGELOG.md | 2 ++ build.gradle | 2 +- .../flowframework/FlowFrameworkPlugin.java | 16 +++++++++++++++- .../flowframework/FlowFrameworkPluginTests.java | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 625864c10..ffe9b399b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ## [Unreleased 2.x](https://github.com/opensearch-project/flow-framework/compare/2.14...2.x) ### Features ### Enhancements +- Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors ([#750](https://github.com/opensearch-project/flow-framework/pull/750)) + ### Bug Fixes ### Infrastructure diff --git a/build.gradle b/build.gradle index 9d69dcb0d..4b50d8190 100644 --- a/build.gradle +++ b/build.gradle @@ -393,7 +393,7 @@ testClusters.integTest { } - // Install Flow Framwork Plugin on integTest cluster nodes + // Install Flow Framework Plugin on integTest cluster nodes plugin(project.tasks.bundlePlugin.archiveFile) // Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1 diff --git a/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java b/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java index 2a728fcb1..c11bf54ad 100644 --- a/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java +++ b/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java @@ -57,9 +57,11 @@ import org.opensearch.flowframework.util.EncryptorUtils; import org.opensearch.flowframework.workflow.WorkflowProcessSorter; import org.opensearch.flowframework.workflow.WorkflowStepFactory; +import org.opensearch.indices.SystemIndexDescriptor; import org.opensearch.ml.client.MachineLearningNodeClient; import org.opensearch.plugins.ActionPlugin; import org.opensearch.plugins.Plugin; +import org.opensearch.plugins.SystemIndexPlugin; import org.opensearch.repositories.RepositoriesService; import org.opensearch.rest.RestController; import org.opensearch.rest.RestHandler; @@ -73,9 +75,12 @@ import java.util.List; import java.util.function.Supplier; +import static org.opensearch.flowframework.common.CommonValue.CONFIG_INDEX; import static org.opensearch.flowframework.common.CommonValue.DEPROVISION_WORKFLOW_THREAD_POOL; import static org.opensearch.flowframework.common.CommonValue.FLOW_FRAMEWORK_THREAD_POOL_PREFIX; +import static org.opensearch.flowframework.common.CommonValue.GLOBAL_CONTEXT_INDEX; import static org.opensearch.flowframework.common.CommonValue.PROVISION_WORKFLOW_THREAD_POOL; +import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_STATE_INDEX; import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_THREAD_POOL; import static org.opensearch.flowframework.common.FlowFrameworkSettings.FLOW_FRAMEWORK_ENABLED; import static org.opensearch.flowframework.common.FlowFrameworkSettings.MAX_WORKFLOWS; @@ -86,7 +91,7 @@ /** * An OpenSearch plugin that enables builders to innovate AI apps on OpenSearch. */ -public class FlowFrameworkPlugin extends Plugin implements ActionPlugin { +public class FlowFrameworkPlugin extends Plugin implements ActionPlugin, SystemIndexPlugin { private FlowFrameworkSettings flowFrameworkSettings; @@ -207,4 +212,13 @@ public List> getExecutorBuilders(Settings settings) { ); } + @Override + public Collection getSystemIndexDescriptors(Settings settings) { + return List.of( + new SystemIndexDescriptor(CONFIG_INDEX, "Flow Framework Config index"), + new SystemIndexDescriptor(GLOBAL_CONTEXT_INDEX, "Flow Framework Global Context index"), + new SystemIndexDescriptor(WORKFLOW_STATE_INDEX, "Flow Framework Workflow State index") + ); + } + } diff --git a/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java b/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java index 401ddbe9a..86224ca26 100644 --- a/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java +++ b/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java @@ -16,11 +16,13 @@ import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; +import org.opensearch.indices.SystemIndexDescriptor; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; import java.io.IOException; +import java.util.Collection; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -86,6 +88,9 @@ public void testPlugin() throws IOException { assertEquals(9, ffp.getActions().size()); assertEquals(3, ffp.getExecutorBuilders(settings).size()); assertEquals(5, ffp.getSettings().size()); + + Collection systemIndexDescriptors = ffp.getSystemIndexDescriptors(Settings.EMPTY); + assertEquals(3, systemIndexDescriptors.size()); } } }