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

Remove exception on failure response from GCS delete API #16047

Conversation

gargvishesh
Copy link
Contributor

@gargvishesh gargvishesh commented Mar 5, 2024

The previously used Google API Client library for Google Cloud Storage returned a 404 HTTPResponseException for delete when the object to be deleted was not found, and was propagated as-is by the Druid GCS extension. The currently used Google Cloud Client library just returns a false response in that scenario, which was being converted to a generic IOException in the extension -- breaking flows where file missing is an acceptable behaviour.

This PR removes the exception altogether since all current delete scenarios don't care if the file-to-be-deleted is missing

@abhishekagarwal87 abhishekagarwal87 added this to the 29.0.1 milestone Mar 5, 2024
@gargvishesh gargvishesh changed the title Throw 404 Exception on failure response from GCS delete API Remove exception on failure response from GCS delete API Mar 5, 2024
if (!storage.get().delete(bucket, path)) {
throw new IOE(
"Failed deleting google cloud storage object [bucket: %s path: %s]",
log.warn(StringUtils.nonStrictFormat(
Copy link
Contributor

Choose a reason for hiding this comment

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

since it was debug previously, lets keep it at debug level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand this is not to spook existing users when they suddenly start seeing warn for missing descriptor.json. Else it better be visible to spot logic bugs.

{
List<Boolean> statuses = storage.get().delete(Iterables.transform(paths, input -> BlobId.of(bucket, input)));
if (statuses.contains(false)) {
throw new IOE("Failed deleting google cloud storage object(s)");
log.warn("Google cloud storage object(s) to be deleted not found");
Copy link
Contributor

Choose a reason for hiding this comment

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

it can be debug level as well. Also please log the paths and bucket

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed and included.

@@ -70,12 +70,12 @@ public void kill(DataSegment segment) throws SegmentLoadingException
// anymore, but we still delete them if exists.
deleteIfPresent(bucket, descriptorPath);
}
catch (IOException e) {
catch (StorageException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleteIfPresent no longer throws IOException

Copy link
Contributor

Choose a reason for hiding this comment

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

the underlying lib could still throw an IOException though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it can't -- else it has to be caught or declared thrown since it's a checked exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could add IOException too here so that any random IO error is bubbled up as SegmentLoadingException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently wIth retry, only 2 exception kinds are possible: a) Exception raised by the retried call (only StorageException in this case), and b) RuntimeException.

Throwables.propagateIfInstanceOf(e, Exception.class);

Do we still want to include IOException handling?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. probably ok to leave.

* change runtime exception class for code coverage
* Add file paths for batch delete failures
Copy link
Contributor Author

@gargvishesh gargvishesh left a comment

Choose a reason for hiding this comment

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

Thank you @abhishekagarwal87 and @abhishekrb19 for the thorough reviews!

Copy link
Contributor

@abhishekrb19 abhishekrb19 left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments swiftly, @gargvishesh! I finished my review of the tests and left a few comments along with some nits, but otherwise looks good.

@abhishekrb19 abhishekrb19 merged commit bed5d9c into apache:master Mar 7, 2024
83 checks passed
gargvishesh added a commit to gargvishesh/druid that referenced this pull request Mar 11, 2024
* Throw 404 Exception on failure response from GCS delete API

* Replace String.format

* Apply suggestions from code review

Co-authored-by: Abhishek Radhakrishnan <[email protected]>

* Remove exception for file not found and fix tests

* Add warn log and fix intellij inspection errors

* More intellij inspection fixes

* * Change to debug log
* change runtime exception class for code coverage
* Add file paths for batch delete failures

* Move failedPaths computation to inside isDebugEnabled flag

* Correct handling of StorageException

* Address review comments

* Remove unused exceptions

* Address code coverage and review comments

* Minor corrections

---------

Co-authored-by: Abhishek Radhakrishnan <[email protected]>
(cherry picked from commit bed5d9c)
gargvishesh added a commit to gargvishesh/druid that referenced this pull request Mar 11, 2024
* Throw 404 Exception on failure response from GCS delete API

* Replace String.format

* Apply suggestions from code review

Co-authored-by: Abhishek Radhakrishnan <[email protected]>

* Remove exception for file not found and fix tests

* Add warn log and fix intellij inspection errors

* More intellij inspection fixes

* * Change to debug log
* change runtime exception class for code coverage
* Add file paths for batch delete failures

* Move failedPaths computation to inside isDebugEnabled flag

* Correct handling of StorageException

* Address review comments

* Remove unused exceptions

* Address code coverage and review comments

* Minor corrections

---------

Co-authored-by: Abhishek Radhakrishnan <[email protected]>
(cherry picked from commit bed5d9c)
abhishekrb19 pushed a commit that referenced this pull request Mar 11, 2024
…6095)

* Throw 404 Exception on failure response from GCS delete API

* Replace String.format

* Apply suggestions from code review

Co-authored-by: Abhishek Radhakrishnan <[email protected]>

* Remove exception for file not found and fix tests

* Add warn log and fix intellij inspection errors

* More intellij inspection fixes

* * Change to debug log
* change runtime exception class for code coverage
* Add file paths for batch delete failures

* Move failedPaths computation to inside isDebugEnabled flag

* Correct handling of StorageException

* Address review comments

* Remove unused exceptions

* Address code coverage and review comments

* Minor corrections

---------

Co-authored-by: Abhishek Radhakrishnan <[email protected]>
(cherry picked from commit bed5d9c)
@cryptoe
Copy link
Contributor

cryptoe commented Mar 12, 2024

Caused because of : #15398

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.

4 participants