Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Fix GRPC AUX_TRANSPORT_PORT and SETTING_GRPC_PORT settings and remove lingering HTTP terminology #17043

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix Shallow copy snapshot failures on closed index ([#16868](https://github.com/opensearch-project/OpenSearch/pull/16868))
- Fix multi-value sort for unsigned long ([#16732](https://github.com/opensearch-project/OpenSearch/pull/16732))
- The `phone-search` analyzer no longer emits the tel/sip prefix, international calling code, extension numbers and unformatted input as a token ([#16993](https://github.com/opensearch-project/OpenSearch/pull/16993))
- Fix GRPC AUX_TRANSPORT_PORT and SETTING_GRPC_PORT settings and remove lingering HTTP terminology ([#17037](https://github.com/opensearch-project/OpenSearch/pull/17037))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.GRPC_TRANSPORT_SETTING_KEY;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_BIND_HOST;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_HOST;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_PORTS;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_PORT;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_PUBLISH_HOST;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_PUBLISH_PORT;
import static org.opensearch.transport.grpc.Netty4GrpcServerTransport.SETTING_GRPC_WORKER_COUNT;
Expand Down Expand Up @@ -58,7 +58,7 @@ public Map<String, Supplier<AuxTransport>> getAuxTransports(
@Override
public List<Setting<?>> getSettings() {
return List.of(
SETTING_GRPC_PORTS,
SETTING_GRPC_PORT,
SETTING_GRPC_HOST,
SETTING_GRPC_PUBLISH_HOST,
SETTING_GRPC_BIND_HOST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@

/**
* Port range on which to bind.
* Note this setting is configured through AffixSetting AUX_TRANSPORT_PORTS where the aux transport type matches the GRPC_TRANSPORT_SETTING_KEY.
* Note this setting is configured through AffixSetting AUX_TRANSPORT_PORT where the aux transport type matches the GRPC_TRANSPORT_SETTING_KEY.
*/
public static final Setting<PortsRange> SETTING_GRPC_PORTS = AUX_TRANSPORT_PORTS.getConcreteSettingForNamespace(
public static final Setting<PortsRange> SETTING_GRPC_PORT = AUX_TRANSPORT_PORT.getConcreteSettingForNamespace(
GRPC_TRANSPORT_SETTING_KEY
);

Expand Down Expand Up @@ -134,20 +134,21 @@
* @param networkService the bind/publish addresses.
*/
public Netty4GrpcServerTransport(Settings settings, List<BindableService> services, NetworkService networkService) {
logger.debug("Initializing Netty4GrpcServerTransport with settings = {}", settings);
this.settings = Objects.requireNonNull(settings);
this.services = Objects.requireNonNull(services);
this.networkService = Objects.requireNonNull(networkService);

final List<String> httpBindHost = SETTING_GRPC_BIND_HOST.get(settings);
this.bindHosts = (httpBindHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : httpBindHost).toArray(
final List<String> grpcBindHost = SETTING_GRPC_BIND_HOST.get(settings);
this.bindHosts = (grpcBindHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : grpcBindHost).toArray(
Strings.EMPTY_ARRAY
);

final List<String> httpPublishHost = SETTING_GRPC_PUBLISH_HOST.get(settings);
this.publishHosts = (httpPublishHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings) : httpPublishHost)
final List<String> grpcPublishHost = SETTING_GRPC_PUBLISH_HOST.get(settings);
this.publishHosts = (grpcPublishHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings) : grpcPublishHost)
.toArray(Strings.EMPTY_ARRAY);

this.port = SETTING_GRPC_PORTS.get(settings);
this.port = SETTING_GRPC_PORT.get(settings);
this.nettyEventLoopThreads = SETTING_GRPC_WORKER_COUNT.get(settings);
}

Expand Down Expand Up @@ -229,7 +230,7 @@
+ publishInetAddress
+ "). "
+ "Please specify a unique port by setting "
+ SETTING_GRPC_PORTS.getKey()
+ SETTING_GRPC_PORT.getKey()

Check warning on line 233 in plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java

View check run for this annotation

Codecov / codecov/patch

plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java#L233

Added line #L233 was not covered by tests
+ " or "
+ SETTING_GRPC_PUBLISH_PORT.getKey()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public void test() {
}

private static Settings createSettings() {
return Settings.builder().put(Netty4GrpcServerTransport.SETTING_GRPC_PORTS.getKey(), getPortRange()).build();
return Settings.builder().put(Netty4GrpcServerTransport.SETTING_GRPC_PORT.getKey(), getPortRange()).build();
}
}
6 changes: 3 additions & 3 deletions server/src/main/java/org/opensearch/bootstrap/Security.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
import static org.opensearch.bootstrap.FilePermissionUtils.addDirectoryPath;
import static org.opensearch.bootstrap.FilePermissionUtils.addSingleFilePath;
import static org.opensearch.plugins.NetworkPlugin.AuxTransport.AUX_PORT_DEFAULTS;
import static org.opensearch.plugins.NetworkPlugin.AuxTransport.AUX_TRANSPORT_PORTS;
import static org.opensearch.plugins.NetworkPlugin.AuxTransport.AUX_TRANSPORT_PORT;
import static org.opensearch.plugins.NetworkPlugin.AuxTransport.AUX_TRANSPORT_TYPES_SETTING;

/**
Expand Down Expand Up @@ -423,7 +423,7 @@
}

/**
* Add dynamic {@link SocketPermission} based on AffixSetting AUX_TRANSPORT_PORTS.
* Add dynamic {@link SocketPermission} based on AffixSetting AUX_TRANSPORT_PORT.
* If an auxiliary transport type is enabled but has no corresponding port range setting fall back to AUX_PORT_DEFAULTS.
*
* @param policy the {@link Permissions} instance to apply the dynamic {@link SocketPermission}s to.
Expand All @@ -432,7 +432,7 @@
private static void addSocketPermissionForAux(final Permissions policy, final Settings settings) {
Set<PortsRange> portsRanges = new HashSet<>();
for (String auxType : AUX_TRANSPORT_TYPES_SETTING.get(settings)) {
Setting<PortsRange> auxTypePortSettings = AUX_TRANSPORT_PORTS.getConcreteSettingForNamespace(auxType);
Setting<PortsRange> auxTypePortSettings = AUX_TRANSPORT_PORT.getConcreteSettingForNamespace(auxType);

Check warning on line 435 in server/src/main/java/org/opensearch/bootstrap/Security.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/bootstrap/Security.java#L435

Added line #L435 was not covered by tests
if (auxTypePortSettings.exists(settings)) {
portsRanges.add(auxTypePortSettings.get(settings));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ abstract class AuxTransport extends AbstractLifecycleComponent {
public static final String AUX_SETTINGS_PREFIX = "aux.transport.";
public static final String AUX_TRANSPORT_TYPES_KEY = AUX_SETTINGS_PREFIX + "types";
public static final String AUX_PORT_DEFAULTS = "9400-9500";
public static final Setting.AffixSetting<PortsRange> AUX_TRANSPORT_PORTS = affixKeySetting(
public static final Setting.AffixSetting<PortsRange> AUX_TRANSPORT_PORT = affixKeySetting(
AUX_SETTINGS_PREFIX,
"ports",
"port",
key -> new Setting<>(key, AUX_PORT_DEFAULTS, PortsRange::new, Setting.Property.NodeScope)
);

Expand Down
Loading