From 587116aa82a9be83ccd809188bd713c4fb9ff031 Mon Sep 17 00:00:00 2001 From: zane-neo Date: Tue, 16 Jan 2024 22:18:37 +0800 Subject: [PATCH] move response out from delete chunk Signed-off-by: zane-neo --- .../ml/action/models/DeleteModelTransportAction.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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