From e740eb3f49f4a2b74227df3cb91f2fb19c59fb7d Mon Sep 17 00:00:00 2001 From: Bhavana Goud Ramaram Date: Fri, 10 Jan 2025 13:48:22 -0600 Subject: [PATCH] adding necessary checks and starting sync_up cron in auto redeployer Signed-off-by: Bhavana Goud Ramaram --- .../ml/autoredeploy/MLModelAutoReDeployer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 aa6bb743c9..509d9f9dc2 100644 --- a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java +++ b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java @@ -184,6 +184,9 @@ private void triggerAutoDeployModels(List addedNodes) { modelAutoRedeployArrangements.add(modelAutoRedeployArrangement); }); redeployAModel(); + } else { + log.info("Could not find any models in the index, not performing auto reloading!"); + startCronjobAndClearListener(); } }, e -> { if (e instanceof IndexNotFoundException) { @@ -215,7 +218,7 @@ private void triggerUndeployModelsOnDataNodes(List dataNodeIds) { client.execute(MLUndeployModelAction.INSTANCE, undeployModelNodesRequest, undeployModelListener); } } - }, e -> { log.error("Failed to query need undeploy models, no action will be performed"); }); + }, e -> { log.error("Failed to query need undeploy models, no action will be performed", e); }); queryRunningModels(listener); } @@ -255,6 +258,11 @@ private void queryRunningModels(ActionListener listener) { @SuppressWarnings("unchecked") private void triggerModelRedeploy(ModelAutoRedeployArrangement modelAutoRedeployArrangement) { + if (modelAutoRedeployArrangement == null) { + log.info("No more models in arrangement, skipping the redeployment"); + startCronjobAndClearListener(); + return; + } String modelId = modelAutoRedeployArrangement.getSearchResponse().getId(); List addedNodes = modelAutoRedeployArrangement.getAddedNodes(); List planningWorkerNodes = (List) modelAutoRedeployArrangement @@ -286,6 +294,7 @@ private void triggerModelRedeploy(ModelAutoRedeployArrangement modelAutoRedeploy .info( "Allow custom deployment plan is true and deploy to all nodes is false and added nodes are not in planning worker nodes list, not to auto redeploy the model to the new nodes!" ); + redeployAModel(); return; }