diff --git a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java index 2d06aad338..ff774ac0be 100644 --- a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java +++ b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java @@ -18,7 +18,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import lombok.Setter; import org.opensearch.action.search.SearchAction; import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java index afeacaf4cd..801b7f0961 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java @@ -32,10 +32,8 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.action.ActionListener; -import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.TermsQueryBuilder; -import org.opensearch.ml.autoredeploy.MLModelAutoReDeployer; import org.opensearch.ml.common.FunctionName; import org.opensearch.ml.common.MLModel; import org.opensearch.ml.common.model.MLModelState; @@ -65,7 +63,6 @@ public class MLSyncUpCron implements Runnable { private volatile Boolean mlConfigInited; @VisibleForTesting Semaphore updateModelStateSemaphore; - private MLModelAutoReDeployer mlModelAutoReDeployer; public MLSyncUpCron( Client client, @@ -247,20 +244,20 @@ void refreshModelState(Map> modelWorkerNodes, Map planningWorkNodes = sourceAsMap.containsKey(MLModel.PLANNING_WORKER_NODES_FIELD) - ? (List) sourceAsMap.get(MLModel.PLANNING_WORKER_NODES_FIELD) - : new ArrayList<>(); + ? (List) sourceAsMap.get(MLModel.PLANNING_WORKER_NODES_FIELD) + : new ArrayList<>(); if (deployToAllNodes) { DiscoveryNode[] eligibleNodes = nodeHelper.getEligibleNodes(functionName); planningWorkerNodeCount = eligibleNodes.length; @@ -273,19 +270,17 @@ void refreshModelState(Map> modelWorkerNodes, Map Instant.now().toEpochMilli())) { + && lastUpdateTime != null + && lastUpdateTime + DEPLOY_MODEL_TASK_GRACE_TIME_IN_MS > Instant.now().toEpochMilli())) { // If model not deployed to any node and no node is deploying the model, then set model state as DEPLOY_FAILED return MLModelState.DEPLOY_FAILED; }