Skip to content

Commit b357936

Browse files
authored
Revert "Support mTLS in Elastic Inference Service plugin (#116423)" (#118765)
This reverts commit 74a4484.
1 parent c1569b2 commit b357936

File tree

22 files changed

+69
-314
lines changed

22 files changed

+69
-314
lines changed

docs/changelog/116423.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,6 @@ static Map<String, Settings> getSSLSettingsMap(Settings settings) {
596596
sslSettingsMap.put(WatcherField.EMAIL_NOTIFICATION_SSL_PREFIX, settings.getByPrefix(WatcherField.EMAIL_NOTIFICATION_SSL_PREFIX));
597597
sslSettingsMap.put(XPackSettings.TRANSPORT_SSL_PREFIX, settings.getByPrefix(XPackSettings.TRANSPORT_SSL_PREFIX));
598598
sslSettingsMap.putAll(getTransportProfileSSLSettings(settings));
599-
// Mount Elastic Inference Service (part of the Inference plugin) configuration
600-
sslSettingsMap.put("xpack.inference.elastic.http.ssl", settings.getByPrefix("xpack.inference.elastic.http.ssl."));
601599
// Only build remote cluster server SSL if the port is enabled
602600
if (REMOTE_CLUSTER_SERVER_ENABLED.get(settings)) {
603601
sslSettingsMap.put(XPackSettings.REMOTE_CLUSTER_SERVER_SSL_PREFIX, getRemoteClusterServerSslSettings(settings));

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public Map<String, IndexStorePlugin.SnapshotCommitSupplier> getSnapshotCommitSup
623623
}
624624

625625
@SuppressWarnings("unchecked")
626-
protected <T> List<T> filterPlugins(Class<T> type) {
626+
private <T> List<T> filterPlugins(Class<T> type) {
627627
return plugins.stream().filter(x -> type.isAssignableFrom(x.getClass())).map(p -> ((T) p)).collect(Collectors.toList());
628628
}
629629

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLServiceTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ public void testGetConfigurationByContextName() throws Exception {
614614
"xpack.security.authc.realms.ldap.realm1.ssl",
615615
"xpack.security.authc.realms.saml.realm2.ssl",
616616
"xpack.monitoring.exporters.mon1.ssl",
617-
"xpack.monitoring.exporters.mon2.ssl",
618-
"xpack.inference.elastic.http.ssl" };
617+
"xpack.monitoring.exporters.mon2.ssl" };
619618

620619
assumeTrue("Not enough cipher suites are available to support this test", getCipherSuites.length >= contextNames.length);
621620

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilterIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.plugins.Plugin;
2323
import org.elasticsearch.search.builder.SearchSourceBuilder;
2424
import org.elasticsearch.test.ESIntegTestCase;
25-
import org.elasticsearch.xpack.inference.LocalStateInferencePlugin;
2625
import org.elasticsearch.xpack.inference.Utils;
2726
import org.elasticsearch.xpack.inference.mock.TestDenseInferenceServiceExtension;
2827
import org.elasticsearch.xpack.inference.mock.TestSparseInferenceServiceExtension;
@@ -59,7 +58,7 @@ public void setup() throws Exception {
5958

6059
@Override
6160
protected Collection<Class<? extends Plugin>> nodePlugins() {
62-
return Arrays.asList(LocalStateInferencePlugin.class);
61+
return Arrays.asList(Utils.TestInferencePlugin.class);
6362
}
6463

6564
public void testBulkOperations() throws Exception {

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.elasticsearch.threadpool.ThreadPool;
3232
import org.elasticsearch.xcontent.ToXContentObject;
3333
import org.elasticsearch.xcontent.XContentBuilder;
34-
import org.elasticsearch.xpack.inference.LocalStateInferencePlugin;
34+
import org.elasticsearch.xpack.inference.InferencePlugin;
3535
import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests;
3636
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
3737
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalModel;
@@ -76,7 +76,7 @@ public void createComponents() {
7676

7777
@Override
7878
protected Collection<Class<? extends Plugin>> getPlugins() {
79-
return pluginList(ReindexPlugin.class, LocalStateInferencePlugin.class);
79+
return pluginList(ReindexPlugin.class, InferencePlugin.class);
8080
}
8181

8282
public void testStoreModel() throws Exception {

x-pack/plugin/inference/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
requires software.amazon.awssdk.retries.api;
3535
requires org.reactivestreams;
3636
requires org.elasticsearch.logging;
37-
requires org.elasticsearch.sslconfig;
3837

3938
exports org.elasticsearch.xpack.inference.action;
4039
exports org.elasticsearch.xpack.inference.registry;

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java

Lines changed: 29 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.indices.SystemIndexDescriptor;
2929
import org.elasticsearch.inference.InferenceServiceExtension;
3030
import org.elasticsearch.inference.InferenceServiceRegistry;
31-
import org.elasticsearch.license.XPackLicenseState;
3231
import org.elasticsearch.node.PluginComponentBinding;
3332
import org.elasticsearch.plugins.ActionPlugin;
3433
import org.elasticsearch.plugins.ExtensiblePlugin;
@@ -46,7 +45,6 @@
4645
import org.elasticsearch.threadpool.ScalingExecutorBuilder;
4746
import org.elasticsearch.xcontent.ParseField;
4847
import org.elasticsearch.xpack.core.ClientHelper;
49-
import org.elasticsearch.xpack.core.XPackPlugin;
5048
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
5149
import org.elasticsearch.xpack.core.inference.action.DeleteInferenceEndpointAction;
5250
import org.elasticsearch.xpack.core.inference.action.GetInferenceDiagnosticsAction;
@@ -56,7 +54,6 @@
5654
import org.elasticsearch.xpack.core.inference.action.PutInferenceModelAction;
5755
import org.elasticsearch.xpack.core.inference.action.UnifiedCompletionAction;
5856
import org.elasticsearch.xpack.core.inference.action.UpdateInferenceModelAction;
59-
import org.elasticsearch.xpack.core.ssl.SSLService;
6057
import org.elasticsearch.xpack.inference.action.TransportDeleteInferenceEndpointAction;
6158
import org.elasticsearch.xpack.inference.action.TransportGetInferenceDiagnosticsAction;
6259
import org.elasticsearch.xpack.inference.action.TransportGetInferenceModelAction;
@@ -121,6 +118,7 @@
121118
import java.util.Map;
122119
import java.util.function.Predicate;
123120
import java.util.function.Supplier;
121+
import java.util.stream.Collectors;
124122
import java.util.stream.Stream;
125123

126124
import static java.util.Collections.singletonList;
@@ -154,7 +152,6 @@ public class InferencePlugin extends Plugin implements ActionPlugin, ExtensibleP
154152
private final Settings settings;
155153
private final SetOnce<HttpRequestSender.Factory> httpFactory = new SetOnce<>();
156154
private final SetOnce<AmazonBedrockRequestSender.Factory> amazonBedrockFactory = new SetOnce<>();
157-
private final SetOnce<HttpRequestSender.Factory> elasicInferenceServiceFactory = new SetOnce<>();
158155
private final SetOnce<ServiceComponents> serviceComponents = new SetOnce<>();
159156
private final SetOnce<ElasticInferenceServiceComponents> elasticInferenceServiceComponents = new SetOnce<>();
160157
private final SetOnce<InferenceServiceRegistry> inferenceServiceRegistry = new SetOnce<>();
@@ -237,31 +234,31 @@ public Collection<?> createComponents(PluginServices services) {
237234
var inferenceServices = new ArrayList<>(inferenceServiceExtensions);
238235
inferenceServices.add(this::getInferenceServiceFactories);
239236

240-
if (isElasticInferenceServiceEnabled()) {
241-
// Create a separate instance of HTTPClientManager with its own SSL configuration (`xpack.inference.elastic.http.ssl.*`).
242-
var elasticInferenceServiceHttpClientManager = HttpClientManager.create(
243-
settings,
244-
services.threadPool(),
245-
services.clusterService(),
246-
throttlerManager,
247-
getSslService()
248-
);
237+
// Set elasticInferenceUrl based on feature flags to support transitioning to the new Elastic Inference Service URL without exposing
238+
// internal names like "eis" or "gateway".
239+
ElasticInferenceServiceSettings inferenceServiceSettings = new ElasticInferenceServiceSettings(settings);
240+
241+
String elasticInferenceUrl = null;
249242

250-
var elasticInferenceServiceRequestSenderFactory = new HttpRequestSender.Factory(
251-
serviceComponents.get(),
252-
elasticInferenceServiceHttpClientManager,
253-
services.clusterService()
243+
if (ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
244+
elasticInferenceUrl = inferenceServiceSettings.getElasticInferenceServiceUrl();
245+
} else if (DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
246+
log.warn(
247+
"Deprecated flag {} detected for enabling {}. Please use {}.",
248+
ELASTIC_INFERENCE_SERVICE_IDENTIFIER,
249+
DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG,
250+
ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG
254251
);
255-
elasicInferenceServiceFactory.set(elasticInferenceServiceRequestSenderFactory);
252+
elasticInferenceUrl = inferenceServiceSettings.getEisGatewayUrl();
253+
}
256254

257-
ElasticInferenceServiceSettings inferenceServiceSettings = new ElasticInferenceServiceSettings(settings);
258-
String elasticInferenceUrl = this.getElasticInferenceServiceUrl(inferenceServiceSettings);
255+
if (elasticInferenceUrl != null) {
259256
elasticInferenceServiceComponents.set(new ElasticInferenceServiceComponents(elasticInferenceUrl));
260257

261258
inferenceServices.add(
262259
() -> List.of(
263260
context -> new ElasticInferenceService(
264-
elasicInferenceServiceFactory.get(),
261+
httpFactory.get(),
265262
serviceComponents.get(),
266263
elasticInferenceServiceComponents.get()
267264
)
@@ -384,21 +381,16 @@ public static ExecutorBuilder<?> inferenceUtilityExecutor(Settings settings) {
384381

385382
@Override
386383
public List<Setting<?>> getSettings() {
387-
ArrayList<Setting<?>> settings = new ArrayList<>();
388-
settings.addAll(HttpSettings.getSettingsDefinitions());
389-
settings.addAll(HttpClientManager.getSettingsDefinitions());
390-
settings.addAll(ThrottlerManager.getSettingsDefinitions());
391-
settings.addAll(RetrySettings.getSettingsDefinitions());
392-
settings.addAll(Truncator.getSettingsDefinitions());
393-
settings.addAll(RequestExecutorServiceSettings.getSettingsDefinitions());
394-
settings.add(SKIP_VALIDATE_AND_START);
395-
396-
// Register Elastic Inference Service settings definitions if the corresponding feature flag is enabled.
397-
if (isElasticInferenceServiceEnabled()) {
398-
settings.addAll(ElasticInferenceServiceSettings.getSettingsDefinitions());
399-
}
400-
401-
return settings;
384+
return Stream.of(
385+
HttpSettings.getSettingsDefinitions(),
386+
HttpClientManager.getSettingsDefinitions(),
387+
ThrottlerManager.getSettingsDefinitions(),
388+
RetrySettings.getSettingsDefinitions(),
389+
ElasticInferenceServiceSettings.getSettingsDefinitions(),
390+
Truncator.getSettingsDefinitions(),
391+
RequestExecutorServiceSettings.getSettingsDefinitions(),
392+
List.of(SKIP_VALIDATE_AND_START)
393+
).flatMap(Collection::stream).collect(Collectors.toList());
402394
}
403395

404396
@Override
@@ -446,10 +438,7 @@ public List<QueryRewriteInterceptor> getQueryRewriteInterceptors() {
446438
@Override
447439
public List<RetrieverSpec<?>> getRetrievers() {
448440
return List.of(
449-
new RetrieverSpec<>(
450-
new ParseField(TextSimilarityRankBuilder.NAME),
451-
(parser, context) -> TextSimilarityRankRetrieverBuilder.fromXContent(parser, context, getLicenseState())
452-
),
441+
new RetrieverSpec<>(new ParseField(TextSimilarityRankBuilder.NAME), TextSimilarityRankRetrieverBuilder::fromXContent),
453442
new RetrieverSpec<>(new ParseField(RandomRankBuilder.NAME), RandomRankRetrieverBuilder::fromXContent)
454443
);
455444
}
@@ -458,36 +447,4 @@ public List<RetrieverSpec<?>> getRetrievers() {
458447
public Map<String, Highlighter> getHighlighters() {
459448
return Map.of(SemanticTextHighlighter.NAME, new SemanticTextHighlighter());
460449
}
461-
462-
// Get Elastic Inference service URL based on feature flags to support transitioning
463-
// to the new Elastic Inference Service URL.
464-
private String getElasticInferenceServiceUrl(ElasticInferenceServiceSettings settings) {
465-
String elasticInferenceUrl = null;
466-
467-
if (ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
468-
elasticInferenceUrl = settings.getElasticInferenceServiceUrl();
469-
} else if (DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
470-
log.warn(
471-
"Deprecated flag {} detected for enabling {}. Please use {}.",
472-
ELASTIC_INFERENCE_SERVICE_IDENTIFIER,
473-
DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG,
474-
ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG
475-
);
476-
elasticInferenceUrl = settings.getEisGatewayUrl();
477-
}
478-
479-
return elasticInferenceUrl;
480-
}
481-
482-
protected Boolean isElasticInferenceServiceEnabled() {
483-
return (ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled() || DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled());
484-
}
485-
486-
protected SSLService getSslService() {
487-
return XPackPlugin.getSharedSslService();
488-
}
489-
490-
protected XPackLicenseState getLicenseState() {
491-
return XPackPlugin.getSharedLicenseState();
492-
}
493450
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/HttpClientManager.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77

88
package org.elasticsearch.xpack.inference.external.http;
99

10-
import org.apache.http.config.Registry;
11-
import org.apache.http.config.RegistryBuilder;
1210
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
1311
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
1412
import org.apache.http.impl.nio.reactor.IOReactorConfig;
15-
import org.apache.http.nio.conn.NoopIOSessionStrategy;
16-
import org.apache.http.nio.conn.SchemeIOSessionStrategy;
17-
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
1813
import org.apache.http.nio.reactor.ConnectingIOReactor;
1914
import org.apache.http.nio.reactor.IOReactorException;
2015
import org.apache.http.pool.PoolStats;
@@ -26,21 +21,18 @@
2621
import org.elasticsearch.common.settings.Settings;
2722
import org.elasticsearch.core.TimeValue;
2823
import org.elasticsearch.threadpool.ThreadPool;
29-
import org.elasticsearch.xpack.core.ssl.SSLService;
3024
import org.elasticsearch.xpack.inference.logging.ThrottlerManager;
3125

3226
import java.io.Closeable;
3327
import java.io.IOException;
3428
import java.util.List;
3529

3630
import static org.elasticsearch.core.Strings.format;
37-
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings.ELASTIC_INFERENCE_SERVICE_SSL_CONFIGURATION_PREFIX;
3831

3932
public class HttpClientManager implements Closeable {
4033
private static final Logger logger = LogManager.getLogger(HttpClientManager.class);
4134
/**
4235
* The maximum number of total connections the connection pool can lease to all routes.
43-
* The configuration applies to each instance of HTTPClientManager (max_total_connections=10 and instances=5 leads to 50 connections).
4436
* From googling around the connection pools maxTotal value should be close to the number of available threads.
4537
*
4638
* https://stackoverflow.com/questions/30989637/how-to-decide-optimal-settings-for-setmaxtotal-and-setdefaultmaxperroute
@@ -55,7 +47,6 @@ public class HttpClientManager implements Closeable {
5547

5648
/**
5749
* The max number of connections a single route can lease.
58-
* This configuration applies to each instance of HttpClientManager.
5950
*/
6051
public static final Setting<Integer> MAX_ROUTE_CONNECTIONS = Setting.intSetting(
6152
"xpack.inference.http.max_route_connections",
@@ -107,22 +98,6 @@ public static HttpClientManager create(
10798
return new HttpClientManager(settings, connectionManager, threadPool, clusterService, throttlerManager);
10899
}
109100

110-
public static HttpClientManager create(
111-
Settings settings,
112-
ThreadPool threadPool,
113-
ClusterService clusterService,
114-
ThrottlerManager throttlerManager,
115-
SSLService sslService
116-
) {
117-
// Set the sslStrategy to ensure an encrypted connection, as Elastic Inference Service requires it.
118-
SSLIOSessionStrategy sslioSessionStrategy = sslService.sslIOSessionStrategy(
119-
sslService.getSSLConfiguration(ELASTIC_INFERENCE_SERVICE_SSL_CONFIGURATION_PREFIX)
120-
);
121-
122-
PoolingNHttpClientConnectionManager connectionManager = createConnectionManager(sslioSessionStrategy);
123-
return new HttpClientManager(settings, connectionManager, threadPool, clusterService, throttlerManager);
124-
}
125-
126101
// Default for testing
127102
HttpClientManager(
128103
Settings settings,
@@ -146,25 +121,6 @@ public static HttpClientManager create(
146121
this.addSettingsUpdateConsumers(clusterService);
147122
}
148123

149-
private static PoolingNHttpClientConnectionManager createConnectionManager(SSLIOSessionStrategy sslStrategy) {
150-
ConnectingIOReactor ioReactor;
151-
try {
152-
var configBuilder = IOReactorConfig.custom().setSoKeepAlive(true);
153-
ioReactor = new DefaultConnectingIOReactor(configBuilder.build());
154-
} catch (IOReactorException e) {
155-
var message = "Failed to initialize HTTP client manager with SSL.";
156-
logger.error(message, e);
157-
throw new ElasticsearchException(message, e);
158-
}
159-
160-
Registry<SchemeIOSessionStrategy> registry = RegistryBuilder.<SchemeIOSessionStrategy>create()
161-
.register("http", NoopIOSessionStrategy.INSTANCE)
162-
.register("https", sslStrategy)
163-
.build();
164-
165-
return new PoolingNHttpClientConnectionManager(ioReactor, registry);
166-
}
167-
168124
private static PoolingNHttpClientConnectionManager createConnectionManager() {
169125
ConnectingIOReactor ioReactor;
170126
try {

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.features.NodeFeature;
1313
import org.elasticsearch.index.query.QueryBuilder;
1414
import org.elasticsearch.license.LicenseUtils;
15-
import org.elasticsearch.license.XPackLicenseState;
1615
import org.elasticsearch.search.builder.SearchSourceBuilder;
1716
import org.elasticsearch.search.rank.RankDoc;
1817
import org.elasticsearch.search.retriever.CompoundRetrieverBuilder;
@@ -22,6 +21,7 @@
2221
import org.elasticsearch.xcontent.ParseField;
2322
import org.elasticsearch.xcontent.XContentBuilder;
2423
import org.elasticsearch.xcontent.XContentParser;
24+
import org.elasticsearch.xpack.core.XPackPlugin;
2525

2626
import java.io.IOException;
2727
import java.util.List;
@@ -73,11 +73,8 @@ public class TextSimilarityRankRetrieverBuilder extends CompoundRetrieverBuilder
7373
RetrieverBuilder.declareBaseParserFields(TextSimilarityRankBuilder.NAME, PARSER);
7474
}
7575

76-
public static TextSimilarityRankRetrieverBuilder fromXContent(
77-
XContentParser parser,
78-
RetrieverParserContext context,
79-
XPackLicenseState licenceState
80-
) throws IOException {
76+
public static TextSimilarityRankRetrieverBuilder fromXContent(XContentParser parser, RetrieverParserContext context)
77+
throws IOException {
8178
if (context.clusterSupportsFeature(TEXT_SIMILARITY_RERANKER_RETRIEVER_SUPPORTED) == false) {
8279
throw new ParsingException(parser.getTokenLocation(), "unknown retriever [" + TextSimilarityRankBuilder.NAME + "]");
8380
}
@@ -86,7 +83,7 @@ public static TextSimilarityRankRetrieverBuilder fromXContent(
8683
"[text_similarity_reranker] retriever composition feature is not supported by all nodes in the cluster"
8784
);
8885
}
89-
if (TextSimilarityRankBuilder.TEXT_SIMILARITY_RERANKER_FEATURE.check(licenceState) == false) {
86+
if (TextSimilarityRankBuilder.TEXT_SIMILARITY_RERANKER_FEATURE.check(XPackPlugin.getSharedLicenseState()) == false) {
9087
throw LicenseUtils.newComplianceException(TextSimilarityRankBuilder.NAME);
9188
}
9289
return PARSER.apply(parser, context);

0 commit comments

Comments
 (0)