diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java index 6f27195b5c..b973801e4d 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java @@ -990,7 +990,7 @@ public void deployModel( mlStats.createModelCounterStatIfAbsent(modelId, ActionName.DEPLOY, ML_ACTION_REQUEST_COUNT).increment(); List workerNodes = mlTask.getWorkerNodes(); if (modelCacheHelper.isModelDeployed(modelId)) { - if (!autoDeployModel && workerNodes != null && workerNodes.size() > 0) { + if (!autoDeployModel && workerNodes != null && !workerNodes.isEmpty()) { log.info("Set new target node ids {} for model {}", Arrays.toString(workerNodes.toArray(new String[0])), modelId); modelCacheHelper.setDeployToAllNodes(modelId, deployToAllNodes); modelCacheHelper.setTargetWorkerNodes(modelId, workerNodes); @@ -999,7 +999,7 @@ public void deployModel( listener.onResponse("successful"); return; } - if (modelCacheHelper.getLocalDeployedModels().length >= maxModelPerNode) { + if (functionName != FunctionName.REMOTE && modelCacheHelper.getLocalDeployedModels().length >= maxModelPerNode) { listener.onFailure(new IllegalArgumentException("Exceed max local model per node limit")); return; }