diff --git a/CHANGELOG.md b/CHANGELOG.md index d6242dff8..53cbbc567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,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 698ae8a56..27c372abd 100644 --- a/build.gradle +++ b/build.gradle @@ -394,7 +394,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()); } } }