From 96a6cbcb1e6121ee6abbcc151b4e2e4f7412b4ba Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Mon, 24 Jun 2024 14:42:47 -0400 Subject: [PATCH 1/4] Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors Signed-off-by: Craig Perkins --- build.gradle | 2 +- .../flowframework/FlowFrameworkPlugin.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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..ab6212220 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; @@ -69,13 +71,17 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.watcher.ResourceWatcherService; +import java.util.ArrayList; import java.util.Collection; 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 +92,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 +213,13 @@ public List> getExecutorBuilders(Settings settings) { ); } + @Override + public Collection getSystemIndexDescriptors(Settings settings) { + List systemIndexDescriptors = new ArrayList<>(); + systemIndexDescriptors.add(new SystemIndexDescriptor(CONFIG_INDEX, "Flow Framework Config index")); + systemIndexDescriptors.add(new SystemIndexDescriptor(GLOBAL_CONTEXT_INDEX, "Flow Framework Global Context index")); + systemIndexDescriptors.add(new SystemIndexDescriptor(WORKFLOW_STATE_INDEX, "Flow Framework Workflow State index")); + return systemIndexDescriptors; + } + } From 8fd29c10fa704e3bfd1fc73a33153b38179bf0bb Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 25 Jun 2024 14:18:46 -0400 Subject: [PATCH 2/4] Add CHANGELOG entry Signed-off-by: Craig Perkins --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6242dff8..244f9c964 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 From b58334613cdb62265235cd2856e00a89ae078a0f Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 26 Jun 2024 09:39:04 -0400 Subject: [PATCH 3/4] Remove extra characters Signed-off-by: Craig Perkins --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 244f9c964..53cbbc567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ### Features ### Enhancements - Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors ([#750](https://github.com/opensearch-project/flow-framework/pull/750)) -- + ### Bug Fixes ### Infrastructure From aaf1f36b0dd19a3f13c9d64c3384f2a0fe5afe4d Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 26 Jun 2024 14:15:31 -0400 Subject: [PATCH 4/4] Address code review comments Signed-off-by: Craig Perkins --- .../opensearch/flowframework/FlowFrameworkPlugin.java | 11 +++++------ .../flowframework/FlowFrameworkPluginTests.java | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java b/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java index ab6212220..c11bf54ad 100644 --- a/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java +++ b/src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java @@ -71,7 +71,6 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.watcher.ResourceWatcherService; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.function.Supplier; @@ -215,11 +214,11 @@ public List> getExecutorBuilders(Settings settings) { @Override public Collection getSystemIndexDescriptors(Settings settings) { - List systemIndexDescriptors = new ArrayList<>(); - systemIndexDescriptors.add(new SystemIndexDescriptor(CONFIG_INDEX, "Flow Framework Config index")); - systemIndexDescriptors.add(new SystemIndexDescriptor(GLOBAL_CONTEXT_INDEX, "Flow Framework Global Context index")); - systemIndexDescriptors.add(new SystemIndexDescriptor(WORKFLOW_STATE_INDEX, "Flow Framework Workflow State index")); - return systemIndexDescriptors; + 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()); } } }