diff --git a/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java index 31ede95e32..b468eba7df 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java @@ -187,7 +187,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener actionListener) { DeleteByQueryRequest deleteModelsRequest = new DeleteByQueryRequest(ML_MODEL_INDEX); deleteModelsRequest.setQuery(new TermsQueryBuilder(MODEL_ID_FIELD, modelId)); - + long startTime = System.currentTimeMillis(); client.execute(DeleteByQueryAction.INSTANCE, deleteModelsRequest, ActionListener.wrap(r -> { if ((r.getBulkFailures() == null || r.getBulkFailures().size() == 0) && (r.getSearchFailures() == null || r.getSearchFailures().size() == 0)) { @@ -197,7 +197,7 @@ void deleteModelChunks(String modelId, DeleteResponse deleteResponse, ActionList // ResourceNotFound is returned to notify that this model was deleted. // This is a walk around to avoid cleaning up model leftovers. Will revisit if // necessary. - actionListener.onResponse(deleteResponse); + log.info("####################################### Delete model chunks success!" + modelId + ", time taken: " + (System.currentTimeMillis() - startTime)); } } else { returnFailure(r, modelId, actionListener); @@ -218,7 +218,8 @@ private void returnFailure(BulkByScrollResponse response, String modelId, Action errorMessage = OS_STATUS_EXCEPTION_MESSAGE + ", " + SEARCH_FAILURE_MSG + modelId; } log.debug(response.toString()); - actionListener.onFailure(new OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR)); + log.info("####################################### Delete model failed!" + modelId + ", response is: " + response); +// actionListener.onFailure(new OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR)); } private void deleteModel(String modelId, ActionListener actionListener) { @@ -229,6 +230,7 @@ public void onResponse(DeleteResponse deleteResponse) { deleteModelChunks(modelId, deleteResponse, actionListener); deleteModelController(modelId); log.info("####################################### Delete model after delete chunks!" + modelId); + actionListener.onResponse(deleteResponse); } @Override