Skip to content

Commit 8f7f6a9

Browse files
committed
move MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL to MLDeploySetting
Signed-off-by: Xun Zhang <xunzh@amazon.com>
1 parent 16416ac commit 8f7f6a9

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

common/src/main/java/org/opensearch/ml/common/model/MLDeploySetting.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.opensearch.core.xcontent.ToXContentObject;
1717
import org.opensearch.core.xcontent.XContentBuilder;
1818
import org.opensearch.core.xcontent.XContentParser;
19-
import org.opensearch.ml.common.transport.sync.MLSyncUpInput;
2019

2120
import java.io.IOException;
2221

@@ -28,6 +27,7 @@ public class MLDeploySetting implements ToXContentObject, Writeable {
2827
public static final String IS_AUTO_DEPLOY_ENABLED_FIELD = "is_auto_deploy_enabled";
2928
public static final String MODEL_TTL_MINUTES_FIELD = "model_ttl_minutes";
3029
private static final long DEFAULT_TTL_MINUTES = -1;
30+
public static final Version MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL = Version.V_2_14_0;
3131

3232
private Boolean isAutoDeployEnabled;
3333
private Long modelTTLInMinutes; // in minutes
@@ -44,7 +44,7 @@ public MLDeploySetting(Boolean isAutoDeployEnabled, Long modelTTLInMinutes) {
4444
public MLDeploySetting(StreamInput in) throws IOException {
4545
this.isAutoDeployEnabled = in.readOptionalBoolean();
4646
Version streamInputVersion = in.getVersion();
47-
if (streamInputVersion.onOrAfter(MLSyncUpInput.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
47+
if (streamInputVersion.onOrAfter(MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
4848
this.modelTTLInMinutes = in.readOptionalLong();
4949
}
5050
}
@@ -53,7 +53,7 @@ public MLDeploySetting(StreamInput in) throws IOException {
5353
public void writeTo(StreamOutput out) throws IOException {
5454
Version streamOutputVersion = out.getVersion();
5555
out.writeOptionalBoolean(isAutoDeployEnabled);
56-
if (streamOutputVersion.onOrAfter(MLSyncUpInput.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
56+
if (streamOutputVersion.onOrAfter(MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
5757
out.writeOptionalLong(modelTTLInMinutes);
5858
}
5959
}

common/src/main/java/org/opensearch/ml/common/transport/sync/MLSyncUpInput.java

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public class MLSyncUpInput implements Writeable {
3636
// profile API has consistent data with model index.
3737
private Map<String, Boolean> deployToAllNodes;
3838

39-
public static final Version MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL = Version.V_2_14_0;
40-
4139
@Builder
4240
public MLSyncUpInput(boolean getDeployedModels,
4341
Map<String, String[]> addedWorkerNodes,

common/src/main/java/org/opensearch/ml/common/transport/sync/MLSyncUpNodeResponse.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.opensearch.cluster.node.DiscoveryNode;
1313
import org.opensearch.core.common.io.stream.StreamInput;
1414
import org.opensearch.core.common.io.stream.StreamOutput;
15+
import org.opensearch.ml.common.model.MLDeploySetting;
1516

1617
import java.io.IOException;
1718

@@ -42,7 +43,7 @@ public MLSyncUpNodeResponse(StreamInput in) throws IOException {
4243
this.deployedModelIds = in.readOptionalStringArray();
4344
this.runningDeployModelIds = in.readOptionalStringArray();
4445
this.runningDeployModelTaskIds = in.readOptionalStringArray();
45-
if (streamInputVersion.onOrAfter(MLSyncUpInput.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
46+
if (streamInputVersion.onOrAfter(MLDeploySetting.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
4647
this.expiredModelIds = in.readOptionalStringArray();
4748
}
4849
}
@@ -59,7 +60,7 @@ public void writeTo(StreamOutput out) throws IOException {
5960
out.writeOptionalStringArray(deployedModelIds);
6061
out.writeOptionalStringArray(runningDeployModelIds);
6162
out.writeOptionalStringArray(runningDeployModelTaskIds);
62-
if (streamOutputVersion.onOrAfter(MLSyncUpInput.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
63+
if (streamOutputVersion.onOrAfter(MLDeploySetting.MINIMAL_SUPPORTED_VERSION_FOR_MODEL_TTL)) {
6364
out.writeOptionalStringArray(expiredModelIds);
6465
}
6566
}

plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public void run() {
140140

141141
Set<String> modelsToUndeploy = new HashSet<>();
142142
for (String modelId : expiredModelToNodes.keySet()) {
143-
if (expiredModelToNodes.get(modelId).size() == modelWorkerNodes.get(modelId).size()) {
143+
if (modelWorkerNodes.containsKey(modelId)
144+
&& expiredModelToNodes.get(modelId).size() == modelWorkerNodes.get(modelId).size()) {
144145
// this model has expired in all the nodes
145146
modelWorkerNodes.remove(modelId);
146147
modelsToUndeploy.add(modelId);

0 commit comments

Comments
 (0)