Skip to content

Commit

Permalink
Evaluate static featureFlags along with system setting while evaluati…
Browse files Browse the repository at this point in the history
…ng featureFlags status
  • Loading branch information
jayehh committed Sep 1, 2023
1 parent 04c90c7 commit 8c5a130
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Encapsulates all valid feature flag level settings.
Expand Down Expand Up @@ -44,4 +46,6 @@ protected FeatureFlagSettings(
)
)
);

public static final Map<String, Setting<?>> FEATURE_FLAG_MAPPING = BUILT_IN_FEATURE_FLAGS.stream().collect(Collectors.toMap(Setting::getKey, features -> features ));
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.common.util;

import org.opensearch.common.settings.FeatureFlagSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Setting.Property;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -87,7 +88,13 @@ public static boolean isEnabled(String featureFlagName) {
// TODO: Remove the if condition once FeatureFlags are only supported via opensearch.yml
return true;
}
return settings != null && settings.getAsBoolean(featureFlagName, false);

boolean defaultValue = false;
if (settings != null && FeatureFlagSettings.FEATURE_FLAG_MAPPING.get(featureFlagName) != null) {
defaultValue = (boolean) FeatureFlagSettings.FEATURE_FLAG_MAPPING.get(featureFlagName).getDefault(settings);
}

return settings != null && settings.getAsBoolean(featureFlagName, defaultValue);
}

public static final Setting<Boolean> SEGMENT_REPLICATION_EXPERIMENTAL_SETTING = Setting.boolSetting(
Expand All @@ -100,7 +107,7 @@ public static boolean isEnabled(String featureFlagName) {

public static final Setting<Boolean> EXTENSIONS_SETTING = Setting.boolSetting(EXTENSIONS, false, Property.NodeScope);

public static final Setting<Boolean> IDENTITY_SETTING = Setting.boolSetting(IDENTITY, false, Property.NodeScope);
public static final Setting<Boolean> IDENTITY_SETTING = Setting.boolSetting(IDENTITY, true, Property.NodeScope);

public static final Setting<Boolean> TELEMETRY_SETTING = Setting.boolSetting(TELEMETRY, false, Property.NodeScope);

Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ protected Node(
FeatureFlags.initializeFeatureFlags(settings);

final List<IdentityPlugin> identityPlugins = new ArrayList<>();
// Todo: Remove after testing
logger.info("jayehh-feature-flag-test: " + FeatureFlags.IDENTITY + " value: " + FeatureFlags.isEnabled(FeatureFlags.IDENTITY));
if (FeatureFlags.isEnabled(FeatureFlags.IDENTITY)) {
// If identity is enabled load plugins implementing the extension point
logger.info("Identity on so found plugins implementing: " + pluginsService.filterPlugins(IdentityPlugin.class).toString());
Expand Down

0 comments on commit 8c5a130

Please sign in to comment.