1212import java .util .ArrayList ;
1313import java .util .Arrays ;
1414import java .util .List ;
15- import java .util .Map ;
1615import java .util .Optional ;
1716import java .util .Queue ;
1817import java .util .concurrent .ConcurrentLinkedQueue ;
3130import org .opensearch .core .common .Strings ;
3231import org .opensearch .index .IndexNotFoundException ;
3332import org .opensearch .index .query .TermsQueryBuilder ;
34- import org .opensearch .ml .common .FunctionName ;
3533import org .opensearch .ml .common .MLModel ;
3634import org .opensearch .ml .common .model .MLModelState ;
3735import org .opensearch .ml .common .transport .deploy .MLDeployModelAction ;
@@ -189,7 +187,6 @@ private void triggerAutoDeployModels(List<String> addedNodes) {
189187 } else {
190188 log .info ("Could not find any models in the index, not performing auto reloading!" );
191189 startCronjobAndClearListener ();
192- return ;
193190 }
194191 }, e -> {
195192 if (e instanceof IndexNotFoundException ) {
@@ -245,9 +242,7 @@ private void queryRunningModels(ActionListener<SearchResponse> listener) {
245242 String [] includes = new String [] {
246243 MLModel .AUTO_REDEPLOY_RETRY_TIMES_FIELD ,
247244 MLModel .PLANNING_WORKER_NODES_FIELD ,
248- MLModel .DEPLOY_TO_ALL_NODES_FIELD ,
249- MLModel .FUNCTION_NAME_FIELD ,
250- MLModel .ALGORITHM_FIELD };
245+ MLModel .DEPLOY_TO_ALL_NODES_FIELD };
251246
252247 String [] excludes = new String [] { MLModel .MODEL_CONTENT_FIELD , MLModel .OLD_MODEL_CONTENT_FIELD };
253248 FetchSourceContext fetchContext = new FetchSourceContext (true , includes , excludes );
@@ -270,27 +265,17 @@ private void triggerModelRedeploy(ModelAutoRedeployArrangement modelAutoRedeploy
270265 }
271266 String modelId = modelAutoRedeployArrangement .getSearchResponse ().getId ();
272267 List <String > addedNodes = modelAutoRedeployArrangement .getAddedNodes ();
273- Map <String , Object > sourceAsMap = modelAutoRedeployArrangement .getSearchResponse ().getSourceAsMap ();
274- String functionName = (String ) Optional
275- .ofNullable (sourceAsMap .get (MLModel .FUNCTION_NAME_FIELD ))
276- .orElse (sourceAsMap .get (MLModel .ALGORITHM_FIELD ));
277- if (functionName == null ) {
278- log
279- .error (
280- "Model function_name or algorithm is null, model is not in correct status, please check the model, model id is: {}" ,
281- modelId
282- );
283- redeployAModel ();
284- return ;
285- }
286- if (FunctionName .REMOTE == FunctionName .from (functionName )) {
287- log .info ("Skipping redeploying remote model {} as remote model deployment can be done at prediction time." , modelId );
288- redeployAModel ();
289- return ;
290- }
291- List <String > planningWorkerNodes = (List <String >) sourceAsMap .get (MLModel .PLANNING_WORKER_NODES_FIELD );
292- Integer autoRedeployRetryTimes = (Integer ) sourceAsMap .get (MLModel .AUTO_REDEPLOY_RETRY_TIMES_FIELD );
293- Boolean deployToAllNodes = (Boolean ) Optional .ofNullable (sourceAsMap .get (MLModel .DEPLOY_TO_ALL_NODES_FIELD )).orElse (false );
268+ List <String > planningWorkerNodes = (List <String >) modelAutoRedeployArrangement
269+ .getSearchResponse ()
270+ .getSourceAsMap ()
271+ .get (MLModel .PLANNING_WORKER_NODES_FIELD );
272+ Integer autoRedeployRetryTimes = (Integer ) modelAutoRedeployArrangement
273+ .getSearchResponse ()
274+ .getSourceAsMap ()
275+ .get (MLModel .AUTO_REDEPLOY_RETRY_TIMES_FIELD );
276+ Boolean deployToAllNodes = (Boolean ) Optional
277+ .ofNullable (modelAutoRedeployArrangement .getSearchResponse ().getSourceAsMap ().get (MLModel .DEPLOY_TO_ALL_NODES_FIELD ))
278+ .orElse (false );
294279 // calculate node ids.
295280 String [] nodeIds = null ;
296281 if (deployToAllNodes || !allowCustomDeploymentPlan ) {
0 commit comments