Skip to content

Commit 8cbd216

Browse files
committed
Revert "[ML] Remove scale to zero feature flag (#114323)"
This reverts commit 3a83fcd.
1 parent 7ad1a0c commit 8cbd216

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum FeatureFlag {
2020
FAILURE_STORE_ENABLED("es.failure_store_feature_flag_enabled=true", Version.fromString("8.12.0"), null),
2121
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
2222
CHUNKING_SETTINGS_ENABLED("es.inference_chunking_settings_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
23+
INFERENCE_SCALE_TO_ZERO("es.inference_scale_to_zero_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
2324
INFERENCE_DEFAULT_ELSER("es.inference_default_elser_feature_flag_enabled=true", Version.fromString("8.16.0"), null);
2425

2526
public final String systemProperty;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScaler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ Integer scale() {
170170
if (maxNumberOfAllocations != null) {
171171
numberOfAllocations = Math.min(numberOfAllocations, maxNumberOfAllocations);
172172
}
173-
if ((minNumberOfAllocations == null || minNumberOfAllocations == 0)
173+
if (ScaleToZeroFeatureFlag.isEnabled()
174+
&& (minNumberOfAllocations == null || minNumberOfAllocations == 0)
174175
&& timeWithoutRequestsSeconds > SCALE_TO_ZERO_AFTER_NO_REQUESTS_TIME_SECONDS) {
175176
logger.debug("[{}] adaptive allocations scaler: scaling down to zero, because of no requests.", deploymentId);
176177
numberOfAllocations = 0;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ private void processDeploymentStats(GetDeploymentStatsAction.Response statsRespo
410410
}
411411

412412
public boolean maybeStartAllocation(TrainedModelAssignment assignment) {
413-
if (assignment.getAdaptiveAllocationsSettings() != null
413+
if (ScaleToZeroFeatureFlag.isEnabled()
414+
&& assignment.getAdaptiveAllocationsSettings() != null
414415
&& assignment.getAdaptiveAllocationsSettings().getEnabled() == Boolean.TRUE) {
415416
lastScaleUpTimesMillis.put(assignment.getDeploymentId(), System.currentTimeMillis());
416417
updateNumberOfAllocations(assignment.getDeploymentId(), 1);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.ml.inference.adaptiveallocations;
9+
10+
import org.elasticsearch.common.util.FeatureFlag;
11+
12+
public class ScaleToZeroFeatureFlag {
13+
private ScaleToZeroFeatureFlag() {}
14+
15+
private static final FeatureFlag FEATURE_FLAG = new FeatureFlag("inference_scale_to_zero");
16+
17+
public static boolean isEnabled() {
18+
return FEATURE_FLAG.isEnabled();
19+
}
20+
}

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ public void testAutoscaling_maxAllocationsSafeguard() {
148148
}
149149

150150
public void testAutoscaling_scaleDownToZeroAllocations() {
151+
assumeTrue("Should only run if adaptive allocations feature flag is enabled", ScaleToZeroFeatureFlag.isEnabled());
152+
151153
AdaptiveAllocationsScaler adaptiveAllocationsScaler = new AdaptiveAllocationsScaler("test-deployment", 1);
152154
// 1 hour with 1 request per 1 seconds, so don't scale.
153155
for (int i = 0; i < 3600; i++) {
@@ -178,6 +180,8 @@ public void testAutoscaling_scaleDownToZeroAllocations() {
178180
}
179181

180182
public void testAutoscaling_dontScaleDownToZeroAllocationsWhenMinAllocationsIsSet() {
183+
assumeTrue("Should only run if adaptive allocations feature flag is enabled", ScaleToZeroFeatureFlag.isEnabled());
184+
181185
AdaptiveAllocationsScaler adaptiveAllocationsScaler = new AdaptiveAllocationsScaler("test-deployment", 1);
182186
adaptiveAllocationsScaler.setMinMaxNumberOfAllocations(1, null);
183187

0 commit comments

Comments
 (0)