From 0d9e606f9ddaabe1a0ea5d8060b987a759251098 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Thu, 31 Oct 2024 11:10:54 -0700 Subject: [PATCH] Feature flag GRPC_ENABLE_SETTING Signed-off-by: Finn Carroll --- .../org/opensearch/common/util/FeatureFlags.java | 13 ++++++++++++- .../grpc/AbstractGrpcServerTransport.java | 3 +-- server/src/main/java/org/opensearch/node/Node.java | 13 +++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/util/FeatureFlags.java b/server/src/main/java/org/opensearch/common/util/FeatureFlags.java index 6df68013a8119..bd5cbb81c47e0 100644 --- a/server/src/main/java/org/opensearch/common/util/FeatureFlags.java +++ b/server/src/main/java/org/opensearch/common/util/FeatureFlags.java @@ -128,6 +128,16 @@ public class FeatureFlags { Property.NodeScope ); + /** + * Gates the functionality of the Netty4 gRPC server. + */ + public static final String GRPC_EXPERIMENTAL = "opensearch.experimental.feature.grpc.enabled"; + public static final Setting GRPC_ENABLE_SETTING = Setting.boolSetting( + GRPC_EXPERIMENTAL, + false, + Property.NodeScope + ); + private static final List> ALL_FEATURE_FLAG_SETTINGS = List.of( REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING, EXTENSIONS_SETTING, @@ -138,7 +148,8 @@ public class FeatureFlags { STAR_TREE_INDEX_SETTING, APPLICATION_BASED_CONFIGURATION_TEMPLATES_SETTING, READER_WRITER_SPLIT_EXPERIMENTAL_SETTING, - TERM_VERSION_PRECOMMIT_ENABLE_SETTING + TERM_VERSION_PRECOMMIT_ENABLE_SETTING, + GRPC_ENABLE_SETTING ); /** diff --git a/server/src/main/java/org/opensearch/grpc/AbstractGrpcServerTransport.java b/server/src/main/java/org/opensearch/grpc/AbstractGrpcServerTransport.java index 03d997aff3f6e..cd56b02d0413b 100644 --- a/server/src/main/java/org/opensearch/grpc/AbstractGrpcServerTransport.java +++ b/server/src/main/java/org/opensearch/grpc/AbstractGrpcServerTransport.java @@ -119,9 +119,8 @@ public GrpcStats stats() { // gRPC service definitions provided at bind abstract protected TransportAddress bindAddress(InetAddress hostAddress, PortsRange portRange); - // TODO: IDENTICAL TO - HTTP SERVER TRANSPORT protected void bindServer() { - InetAddress hostAddresses[]; + InetAddress[] hostAddresses; try { hostAddresses = networkService.resolveBindHostAddresses(bindHosts); } catch (IOException e) { diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 7ddfc28d0a888..f8e7ba750b504 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -313,7 +313,9 @@ import static java.util.stream.Collectors.toList; import static org.opensearch.common.util.FeatureFlags.BACKGROUND_TASK_EXECUTION_EXPERIMENTAL; +import static org.opensearch.common.util.FeatureFlags.GRPC_ENABLE_SETTING; import static org.opensearch.common.util.FeatureFlags.TELEMETRY; +import static org.opensearch.common.util.FeatureFlags.initializeFeatureFlags; import static org.opensearch.env.NodeEnvironment.collectFileCacheDataPath; import static org.opensearch.index.ShardIndexingPressureSettings.SHARD_INDEXING_PRESSURE_ENABLED_ATTRIBUTE_KEY; import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_PINNED_TIMESTAMP_ENABLED; @@ -1753,16 +1755,19 @@ public void onTimeout(TimeValue timeout) { injector.getInstance(HttpServerTransport.class).start(); - // TODO: FEATURE FLAG HERE? - injector.getInstance(GrpcServerTransport.class).start(); + if (FeatureFlags.isEnabled(GRPC_ENABLE_SETTING)) { + injector.getInstance(GrpcServerTransport.class).start(); + } if (WRITE_PORTS_FILE_SETTING.get(settings())) { TransportService transport = injector.getInstance(TransportService.class); writePortsFile("transport", transport.boundAddress()); HttpServerTransport http = injector.getInstance(HttpServerTransport.class); writePortsFile("http", http.boundAddress()); - GrpcServerTransport grpc = injector.getInstance(GrpcServerTransport.class); - writePortsFile("grpc", grpc.boundAddress()); + if (FeatureFlags.isEnabled(GRPC_ENABLE_SETTING)) { + GrpcServerTransport grpc = injector.getInstance(GrpcServerTransport.class); + writePortsFile("grpc", grpc.boundAddress()); + } } logger.info("started");