Skip to content

Commit 730ec3e

Browse files
authored
[8.x][ML] Remove Elastic Inference Service feature flag (#121093)
* Remove Elastic Inference Service feature flag * Update docs/changelog/121093.yaml * Fix after rebasing * Remove obsolete config value * Remove obsolete class * Delete docs/changelog/121093.yaml
1 parent f798c11 commit 730ec3e

File tree

7 files changed

+60
-208
lines changed

7 files changed

+60
-208
lines changed

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/BaseMockEISAuthServerTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public class BaseMockEISAuthServerTest extends ESRestTestCase {
3939
.setting("xpack.security.enabled", "true")
4040
// Adding both settings unless one feature flag is disabled in a particular environment
4141
.setting("xpack.inference.elastic.url", mockEISServer::getUrl)
42-
// TODO remove this once we've removed DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG and EIS_GATEWAY_URL
43-
.setting("xpack.inference.eis.gateway.url", mockEISServer::getUrl)
4442
// This plugin is located in the inference/qa/test-service-plugin package, look for TestInferenceServicePlugin
4543
.plugin("inference-service-test")
4644
.user("x_pack_rest_user", "x-pack-test-password")

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetModelsWithElasticInferenceServiceIT.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.xpack.inference;
1111

1212
import org.elasticsearch.inference.TaskType;
13-
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature;
1413

1514
import java.io.IOException;
1615

@@ -24,18 +23,11 @@ public void testGetDefaultEndpoints() throws IOException {
2423
var allModels = getAllModels();
2524
var chatCompletionModels = getModels("_all", TaskType.CHAT_COMPLETION);
2625

27-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
28-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
29-
assertThat(allModels, hasSize(4));
30-
assertThat(chatCompletionModels, hasSize(1));
31-
32-
for (var model : chatCompletionModels) {
33-
assertEquals("chat_completion", model.get("task_type"));
34-
}
35-
} else {
36-
assertThat(allModels, hasSize(3));
37-
assertThat(chatCompletionModels, hasSize(0));
38-
}
26+
assertThat(allModels, hasSize(4));
27+
assertThat(chatCompletionModels, hasSize(1));
3928

29+
for (var model : chatCompletionModels) {
30+
assertEquals("chat_completion", model.get("task_type"));
31+
}
4032
}
4133
}

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
import org.elasticsearch.client.Request;
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.inference.TaskType;
15-
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature;
1615

1716
import java.io.IOException;
1817
import java.util.ArrayList;
19-
import java.util.Arrays;
2018
import java.util.List;
2119
import java.util.Map;
2220

@@ -28,27 +26,23 @@ public class InferenceGetServicesIT extends BaseMockEISAuthServerTest {
2826
@SuppressWarnings("unchecked")
2927
public void testGetServicesWithoutTaskType() throws IOException {
3028
List<Object> services = getAllServices();
31-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
32-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
33-
assertThat(services.size(), equalTo(19));
34-
} else {
35-
assertThat(services.size(), equalTo(18));
36-
}
29+
assertThat(services.size(), equalTo(19));
3730

3831
String[] providers = new String[services.size()];
3932
for (int i = 0; i < services.size(); i++) {
4033
Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i);
4134
providers[i] = (String) serviceConfig.get("service");
4235
}
4336

44-
var providerList = new ArrayList<>(
45-
Arrays.asList(
37+
assertArrayEquals(
38+
List.of(
4639
"alibabacloud-ai-search",
4740
"amazonbedrock",
4841
"anthropic",
4942
"azureaistudio",
5043
"azureopenai",
5144
"cohere",
45+
"elastic",
5246
"elasticsearch",
5347
"googleaistudio",
5448
"googlevertexai",
@@ -61,13 +55,9 @@ public void testGetServicesWithoutTaskType() throws IOException {
6155
"test_service",
6256
"text_embedding_test_service",
6357
"watsonxai"
64-
)
58+
).toArray(),
59+
providers
6560
);
66-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
67-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
68-
providerList.add(6, "elastic");
69-
}
70-
assertArrayEquals(providerList.toArray(), providers);
7161
}
7262

7363
@SuppressWarnings("unchecked")
@@ -150,52 +140,33 @@ public void testGetServicesWithCompletionTaskType() throws IOException {
150140
@SuppressWarnings("unchecked")
151141
public void testGetServicesWithChatCompletionTaskType() throws IOException {
152142
List<Object> services = getServices(TaskType.CHAT_COMPLETION);
153-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
154-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
155-
assertThat(services.size(), equalTo(3));
156-
} else {
157-
assertThat(services.size(), equalTo(2));
158-
}
143+
assertThat(services.size(), equalTo(3));
159144

160145
String[] providers = new String[services.size()];
161146
for (int i = 0; i < services.size(); i++) {
162147
Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i);
163148
providers[i] = (String) serviceConfig.get("service");
164149
}
165150

166-
var providerList = new ArrayList<>(List.of("openai", "streaming_completion_test_service"));
167-
168-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
169-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
170-
providerList.add(0, "elastic");
171-
}
172-
173-
assertArrayEquals(providers, providerList.toArray());
151+
assertArrayEquals(List.of("elastic", "openai", "streaming_completion_test_service").toArray(), providers);
174152
}
175153

176154
@SuppressWarnings("unchecked")
177155
public void testGetServicesWithSparseEmbeddingTaskType() throws IOException {
178156
List<Object> services = getServices(TaskType.SPARSE_EMBEDDING);
179157

180-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
181-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
182-
assertThat(services.size(), equalTo(5));
183-
} else {
184-
assertThat(services.size(), equalTo(4));
185-
}
158+
assertThat(services.size(), equalTo(5));
186159

187160
String[] providers = new String[services.size()];
188161
for (int i = 0; i < services.size(); i++) {
189162
Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i);
190163
providers[i] = (String) serviceConfig.get("service");
191164
}
192165

193-
var providerList = new ArrayList<>(Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "test_service"));
194-
if ((ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()
195-
|| ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled())) {
196-
providerList.add(1, "elastic");
197-
}
198-
assertArrayEquals(providers, providerList.toArray());
166+
assertArrayEquals(
167+
List.of("alibabacloud-ai-search", "elastic", "elasticsearch", "hugging_face", "test_service").toArray(),
168+
providers
169+
);
199170
}
200171

201172
private List<Object> getAllServices() throws IOException {

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

Lines changed: 39 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@
133133
import java.util.function.Supplier;
134134

135135
import static java.util.Collections.singletonList;
136-
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceService.ELASTIC_INFERENCE_SERVICE_IDENTIFIER;
137-
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature.DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG;
138-
import static org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG;
139136

140137
public class InferencePlugin extends Plugin
141138
implements
@@ -252,46 +249,44 @@ public Collection<?> createComponents(PluginServices services) {
252249
var inferenceServices = new ArrayList<>(inferenceServiceExtensions);
253250
inferenceServices.add(this::getInferenceServiceFactories);
254251

255-
if (isElasticInferenceServiceEnabled()) {
256-
// Create a separate instance of HTTPClientManager with its own SSL configuration (`xpack.inference.elastic.http.ssl.*`).
257-
var elasticInferenceServiceHttpClientManager = HttpClientManager.create(
258-
settings,
259-
services.threadPool(),
260-
services.clusterService(),
261-
throttlerManager,
262-
getSslService()
263-
);
264-
265-
var elasticInferenceServiceRequestSenderFactory = new HttpRequestSender.Factory(
266-
serviceComponents.get(),
267-
elasticInferenceServiceHttpClientManager,
268-
services.clusterService()
269-
);
270-
elasicInferenceServiceFactory.set(elasticInferenceServiceRequestSenderFactory);
271-
272-
ElasticInferenceServiceSettings inferenceServiceSettings = new ElasticInferenceServiceSettings(settings);
273-
String elasticInferenceUrl = this.getElasticInferenceServiceUrl(inferenceServiceSettings);
274-
275-
var elasticInferenceServiceComponentsInstance = new ElasticInferenceServiceComponents(elasticInferenceUrl);
276-
elasticInferenceServiceComponents.set(elasticInferenceServiceComponentsInstance);
277-
278-
var authorizationHandler = new ElasticInferenceServiceAuthorizationHandler(
279-
elasticInferenceServiceComponentsInstance.elasticInferenceServiceUrl(),
280-
services.threadPool()
281-
);
282-
283-
inferenceServices.add(
284-
() -> List.of(
285-
context -> new ElasticInferenceService(
286-
elasicInferenceServiceFactory.get(),
287-
serviceComponents.get(),
288-
elasticInferenceServiceComponentsInstance,
289-
modelRegistry,
290-
authorizationHandler
291-
)
252+
// Create a separate instance of HTTPClientManager with its own SSL configuration (`xpack.inference.elastic.http.ssl.*`).
253+
var elasticInferenceServiceHttpClientManager = HttpClientManager.create(
254+
settings,
255+
services.threadPool(),
256+
services.clusterService(),
257+
throttlerManager,
258+
getSslService()
259+
);
260+
261+
var elasticInferenceServiceRequestSenderFactory = new HttpRequestSender.Factory(
262+
serviceComponents.get(),
263+
elasticInferenceServiceHttpClientManager,
264+
services.clusterService()
265+
);
266+
elasicInferenceServiceFactory.set(elasticInferenceServiceRequestSenderFactory);
267+
268+
ElasticInferenceServiceSettings inferenceServiceSettings = new ElasticInferenceServiceSettings(settings);
269+
String elasticInferenceUrl = inferenceServiceSettings.getElasticInferenceServiceUrl();
270+
271+
var elasticInferenceServiceComponentsInstance = new ElasticInferenceServiceComponents(elasticInferenceUrl);
272+
elasticInferenceServiceComponents.set(elasticInferenceServiceComponentsInstance);
273+
274+
var authorizationHandler = new ElasticInferenceServiceAuthorizationHandler(
275+
elasticInferenceServiceComponentsInstance.elasticInferenceServiceUrl(),
276+
services.threadPool()
277+
);
278+
279+
inferenceServices.add(
280+
() -> List.of(
281+
context -> new ElasticInferenceService(
282+
elasicInferenceServiceFactory.get(),
283+
serviceComponents.get(),
284+
elasticInferenceServiceComponentsInstance,
285+
modelRegistry,
286+
authorizationHandler
292287
)
293-
);
294-
}
288+
)
289+
);
295290

296291
var factoryContext = new InferenceServiceExtension.InferenceServiceFactoryContext(
297292
services.client(),
@@ -420,11 +415,7 @@ public List<Setting<?>> getSettings() {
420415
settings.addAll(Truncator.getSettingsDefinitions());
421416
settings.addAll(RequestExecutorServiceSettings.getSettingsDefinitions());
422417
settings.add(SKIP_VALIDATE_AND_START);
423-
424-
// Register Elastic Inference Service settings definitions if the corresponding feature flag is enabled.
425-
if (isElasticInferenceServiceEnabled()) {
426-
settings.addAll(ElasticInferenceServiceSettings.getSettingsDefinitions());
427-
}
418+
settings.addAll(ElasticInferenceServiceSettings.getSettingsDefinitions());
428419

429420
return settings;
430421
}
@@ -499,25 +490,7 @@ public Map<String, Highlighter> getHighlighters() {
499490
// Get Elastic Inference service URL based on feature flags to support transitioning
500491
// to the new Elastic Inference Service URL.
501492
private String getElasticInferenceServiceUrl(ElasticInferenceServiceSettings settings) {
502-
String elasticInferenceUrl = null;
503-
504-
if (ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
505-
elasticInferenceUrl = settings.getElasticInferenceServiceUrl();
506-
} else if (DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
507-
log.warn(
508-
"Deprecated flag {} detected for enabling {}. Please use {}.",
509-
ELASTIC_INFERENCE_SERVICE_IDENTIFIER,
510-
DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG,
511-
ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG
512-
);
513-
elasticInferenceUrl = settings.getEisGatewayUrl();
514-
}
515-
516-
return elasticInferenceUrl;
517-
}
518-
519-
protected Boolean isElasticInferenceServiceEnabled() {
520-
return (ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled() || DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled());
493+
return settings.getElasticInferenceServiceUrl();
521494
}
522495

523496
protected SSLService getSslService() {

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceFeature.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
import org.elasticsearch.common.util.FeatureFlag;
1111

1212
/**
13-
* Elastic Inference Service (EIS) feature flag. When the feature is complete, this flag will be removed.
14-
* Enable feature via JVM option: `-Des.elastic_inference_service_feature_flag_enabled=true`.
13+
* Elastic Inference Service feature flag. Not being used anymore, but we'll keep it until the controller is no longer
14+
* passing -Des.elastic_inference_service_feature_flag_enabled=true at startup.
1515
*/
1616
public class ElasticInferenceServiceFeature {
1717

18-
// TODO when we remove this also look in InferenceGetServicesIT and remove references to the deprecated URL setting
1918
@Deprecated
20-
public static final FeatureFlag DEPRECATED_ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG = new FeatureFlag("eis");
21-
2219
public static final FeatureFlag ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG = new FeatureFlag("elastic_inference_service");
20+
2321
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSettings.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,16 @@
2020
*/
2121
public class ElasticInferenceServiceSettings {
2222

23-
// TODO when we remove this look at InferenceGetServicesIT and remove the setting there as well
24-
@Deprecated
25-
static final Setting<String> EIS_GATEWAY_URL = Setting.simpleString("xpack.inference.eis.gateway.url", Setting.Property.NodeScope);
26-
2723
public static final String ELASTIC_INFERENCE_SERVICE_SSL_CONFIGURATION_PREFIX = "xpack.inference.elastic.http.ssl.";
2824

2925
static final Setting<String> ELASTIC_INFERENCE_SERVICE_URL = Setting.simpleString(
3026
"xpack.inference.elastic.url",
3127
Setting.Property.NodeScope
3228
);
3329

34-
// Adjust this variable to be volatile, if the setting can be updated at some point in time
35-
@Deprecated
36-
private final String eisGatewayUrl;
37-
3830
private final String elasticInferenceServiceUrl;
3931

4032
public ElasticInferenceServiceSettings(Settings settings) {
41-
eisGatewayUrl = EIS_GATEWAY_URL.get(settings);
4233
elasticInferenceServiceUrl = ELASTIC_INFERENCE_SERVICE_URL.get(settings);
4334
}
4435

@@ -55,19 +46,13 @@ public ElasticInferenceServiceSettings(Settings settings) {
5546

5647
public static List<Setting<?>> getSettingsDefinitions() {
5748
ArrayList<Setting<?>> settings = new ArrayList<>();
58-
settings.add(EIS_GATEWAY_URL);
5949
settings.add(ELASTIC_INFERENCE_SERVICE_URL);
6050
settings.add(ELASTIC_INFERENCE_SERVICE_SSL_ENABLED);
6151
settings.addAll(ELASTIC_INFERENCE_SERVICE_SSL_CONFIGURATION_SETTINGS.getEnabledSettings());
6252

6353
return settings;
6454
}
6555

66-
@Deprecated
67-
public String getEisGatewayUrl() {
68-
return eisGatewayUrl;
69-
}
70-
7156
public String getElasticInferenceServiceUrl() {
7257
return elasticInferenceServiceUrl;
7358
}

0 commit comments

Comments
 (0)