Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw errors on model deletion failures #834

Merged
merged 8 commits into from
Apr 13, 2023

Conversation

jmazanec15
Copy link
Member

Description

Throws errors on model deletion. Previously we were indicating failure, but returning 200 response codes. This changes that to throw exceptions with the correct response code.

Deprecates constructor for DeleteModelResponse that takes an error/result, as this result should only be returned on success.

Issues Resolved

#831

Check List

  • Commits are signed as per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@jmazanec15 jmazanec15 added the Bug Fixes Changes to a system or product designed to handle a programming bug/glitch label Mar 31, 2023
@jmazanec15 jmazanec15 requested a review from a team March 31, 2023 22:04
Comment on lines 465 to 491
Exception e = new ResourceNotFoundException(errorMessage);
logger.error(e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really interesting use of exception. In general we log the exception trace so that we know from where exception came. but here this is not the case.

If we put a log.error message here will that not be sufficient?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need exception instance to pass it to the listener.onFailure, I guess that's the main reason why we create it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we log the exception trace so that we know from where exception came. but here this is not the case.

Im not sure what you mean by this. I wanted to log the error here so that we can see the complete stack trace. We can also just log the errorMessage, but I felt adding additional information about the exception would be helpful.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What information you are adding here? I see log can do the job.

Im not sure what you mean by this.

What I mean was why not log the error message in when listener.onFailure(e); is executed, which is the line just below this code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I updated.

Comment on lines 493 to 520
String errorMessage = String.format("Cannot delete model [%s]. Model is still in training", modelId);
Exception e = new DeleteModelWhenInTrainStateException(errorMessage);
logger.error(e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will track discussion above.

@naveentatikonda
Copy link
Member

@jmazanec15
Copy link
Member Author

@naveentatikonda yes, I missed that one. Will update.

@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2023

Codecov Report

Merging #834 (02f7129) into main (1b6fd48) will decrease coverage by 0.14%.
The diff coverage is 79.16%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #834      +/-   ##
============================================
- Coverage     85.42%   85.28%   -0.14%     
- Complexity     1091     1092       +1     
============================================
  Files           152      153       +1     
  Lines          4404     4417      +13     
  Branches        393      392       -1     
============================================
+ Hits           3762     3767       +5     
- Misses          465      473       +8     
  Partials        177      177              
Impacted Files Coverage Δ
...main/java/org/opensearch/knn/indices/ModelDao.java 80.87% <68.75%> (-0.69%) ⬇️
...xception/DeleteModelWhenInTrainStateException.java 100.00% <100.00%> (ø)
...arch/knn/plugin/transport/DeleteModelResponse.java 81.48% <100.00%> (-18.52%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jmazanec15 jmazanec15 force-pushed the issue-831 branch 3 times, most recently from cd6d8b0 to 6b20a9d Compare April 6, 2023 17:39
Throws errors on model deletion. Previously we were indicating failure,
but returning 200 response codes. This changes that to throw exceptions
with the correct response code.

Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
Signed-off-by: John Mazanec <jmazane@amazon.com>
@jmazanec15
Copy link
Member Author

Failure on windows related to: opensearch-project/OpenSearch#7080.

Please review @naveentatikonda @martin-gaievski @navneet1v

@jmazanec15 jmazanec15 merged commit 5c3bf53 into opensearch-project:main Apr 13, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 13, 2023
Throws errors on model deletion. Previously we were indicating failure,
but returning 200 response codes. This changes that to throw exceptions
with the correct response code.

Signed-off-by: John Mazanec <jmazane@amazon.com>
(cherry picked from commit 5c3bf53)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 13, 2023
Throws errors on model deletion. Previously we were indicating failure,
but returning 200 response codes. This changes that to throw exceptions
with the correct response code.

Signed-off-by: John Mazanec <jmazane@amazon.com>
(cherry picked from commit 5c3bf53)
naveentatikonda pushed a commit that referenced this pull request Apr 13, 2023
Throws errors on model deletion. Previously we were indicating failure,
but returning 200 response codes. This changes that to throw exceptions
with the correct response code.

Signed-off-by: John Mazanec <jmazane@amazon.com>
(cherry picked from commit 5c3bf53)

Co-authored-by: John Mazanec <jmazane@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.7 Bug Fixes Changes to a system or product designed to handle a programming bug/glitch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants