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

[Feature/multi_tenancy] Restore original exception handling expectations #2507

Conversation

dbwiddis
Copy link
Member

@dbwiddis dbwiddis commented Jun 5, 2024

Description

Restores the original exception handling behavior for connector transport actions

Issues Resolved

Resolves TODO from #2459

Open question: should the non-runtime exceptions be wrapped in an UndeclaredThrowableException rather than an OpenSearchStatusException? I'm thinking probably.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed 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.

@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Failure
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Failure
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:31 — with GitHub Actions Error
@dbwiddis dbwiddis force-pushed the exception-handling branch from 6f20123 to 9ddfe16 Compare June 5, 2024 21:56
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Failure
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Error
@dbwiddis dbwiddis had a problem deploying to ml-commons-cicd-env June 5, 2024 21:56 — with GitHub Actions Failure
@dbwiddis dbwiddis force-pushed the exception-handling branch from 9ddfe16 to 22a0ce5 Compare June 6, 2024 01:03
@dbwiddis dbwiddis temporarily deployed to ml-commons-cicd-env June 6, 2024 01:03 — with GitHub Actions Inactive
@dbwiddis dbwiddis temporarily deployed to ml-commons-cicd-env June 6, 2024 01:03 — with GitHub Actions Inactive
@dbwiddis dbwiddis temporarily deployed to ml-commons-cicd-env June 6, 2024 01:03 — with GitHub Actions Inactive
@dbwiddis dbwiddis temporarily deployed to ml-commons-cicd-env June 6, 2024 01:04 — with GitHub Actions Inactive
@@ -114,7 +124,12 @@ default DeleteDataObjectResponse deleteDataObject(DeleteDataObjectRequest reques
if (cause instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw new OpenSearchException(cause);
// Rethrow unchecked Exceptions
if (cause instanceof RuntimeException) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about other Exceptions like: IllegalArgumentException, IOException, MLException

Copy link
Member Author

Choose a reason for hiding this comment

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

IllegalArgumentException and MLException are both subclasses of RuntimeException so will be thrown here as the original exception.

IOException is a checked exception so is wrapped in an unchecked exception before throwing.

See the PR description where I suggested possibly wrapping in an UndeclaredThrowableException instead of OpenSearchException.

Do you have an alternative proposal here? If we don't rethrow checked exceptions we need to add throws clauses to every one of these API methods.

Copy link
Collaborator

@dhrubo-os dhrubo-os Jun 14, 2024

Choose a reason for hiding this comment

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

We have MLException class, may be we can re-use them?

Copy link
Member Author

Choose a reason for hiding this comment

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

These clients aren't unique to ML Commons. The exceptions should be generic. This class will not be in ML Commons eventually and shouldn't need to add it as a dependency.

The intent here is to rethrow the original exception whenever possible, and if not, pass a throwable with the original exception as its cause.

Comment on lines +49 to +54
// Rethrow unchecked Exceptions
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else {
throw new OpenSearchException(cause);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that CompletionException extends RunTimeException do we except non-RunTimeException?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we "expect"? No. But I spent quite some time debugging a mysterious NullPointerException which was swallowed without handling like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I've already extracted the cause from the Completion Exception:

Throwable cause = e.getCause();

@dhrubo-os
Copy link
Collaborator

closing this PR in favor of #2520

@dhrubo-os dhrubo-os closed this Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants