Skip to content

Commit

Permalink
Initialize feature flags before extensions manager (#6082)
Browse files Browse the repository at this point in the history
* Initialize feature flags before extensions manager

Signed-off-by: Craig Perkins <cwperx@amazon.com>
(cherry picked from commit 3164a3a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Feb 3, 2023
1 parent 5c92ebf commit ae779bd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.extensions;

import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.test.OpenSearchIntegTestCase;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class ExtensionsManagerIT extends OpenSearchIntegTestCase {

@Override
protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.EXTENSIONS, "true").build();
}

public void testExtensionsManagerCreation() {
String nodeName = internalCluster().startNode();

ensureGreen();

ExtensionsManager extManager = internalCluster().getInstance(ExtensionsManager.class, nodeName);

assertEquals(ExtensionsManager.class.getName(), extManager.getClass().getName());
}
}
14 changes: 6 additions & 8 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,17 @@ protected Node(
classpathPlugins
);

final Settings settings = pluginsService.updatedSettings();

// Ensure to initialize Feature Flags via the settings from opensearch.yml
FeatureFlags.initializeFeatureFlags(settings);

if (FeatureFlags.isEnabled(FeatureFlags.EXTENSIONS)) {
this.extensionsManager = new ExtensionsManager(tmpSettings, initialEnvironment.extensionDir());
} else {
this.extensionsManager = new NoopExtensionsManager();
}

final Settings settings = pluginsService.updatedSettings();

// Ensure to initialize Feature Flags via the settings from opensearch.yml
FeatureFlags.initializeFeatureFlags(settings);

final Set<DiscoveryNodeRole> additionalRoles = pluginsService.filterPlugins(Plugin.class)
.stream()
.map(Plugin::getRoles)
Expand Down Expand Up @@ -1008,9 +1008,7 @@ protected Node(
b.bind(Client.class).toInstance(client);
b.bind(NodeClient.class).toInstance(client);
b.bind(Environment.class).toInstance(this.environment);
if (FeatureFlags.isEnabled(FeatureFlags.EXTENSIONS)) {
b.bind(ExtensionsManager.class).toInstance(this.extensionsManager);
}
b.bind(ExtensionsManager.class).toInstance(this.extensionsManager);
b.bind(ThreadPool.class).toInstance(threadPool);
b.bind(NodeEnvironment.class).toInstance(nodeEnvironment);
b.bind(ResourceWatcherService.class).toInstance(resourceWatcherService);
Expand Down

0 comments on commit ae779bd

Please sign in to comment.