opensearch-project / ml-commons

ml-commons provides a set of common machine learning algorithms, e.g. k-means, or linear regression, to help developers build ML related features within OpenSearch.
Apache License 2.0
89 stars 126 forks source link

[BUG] Deleting a not-found model or agent via the MLClient throws an exception #2751

Open dbwiddis opened 1 month ago

dbwiddis commented 1 month ago

What is the bug?

When using the ML Client to delete a model or agent which does not exist, the ActionListener failure path is followed with an OpenSearchStatusException with status NOT_FOUND.

This does not match the pattern for Connectors and OpenSearch document deletion where the a DeleteResponse is sent indicating success, but includes a DocWriteResponse.Result.NOT_FOUND result.

How can one reproduce the bug? Steps to reproduce the behavior:

  1. Use the MLClient to register a model or agent
  2. Use the REST API to delete that model or agent
  3. Use the MLClient to unregister/delete that model or agent
  4. The ActionListener fails with exception

What is the expected behavior?

ActionListener should send onResponse with a DeleteResponse with NOT_FOUND result.

Suggested FIx

Clearly document "delete" APIs that send DeleteResponse which do not follow the usual pattern.

ylwu-amzn commented 1 month ago

This will be a breaking change. If some user have code/scripts checking exception returned from delete API , their code will break.

Why not change the client side logic to check the error ?

dbwiddis commented 1 month ago

I am changing the client. But this is an unusual pattern and should be clearly documented as such. MLClient users should not have to look in the code to see that deletion does not follow the same pattern as expected.

ylwu-amzn commented 1 month ago

Make sense, create a document issue to track this : https://github.com/opensearch-project/documentation-website/issues/7838