-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add exception mappers to convert storage failures to Iceberg REST client exceptions #8558
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7c038ea
Add exception mappers to convert storage failures to Iceberg REST cli…
dimas-b 12fd3ae
Fix helm
dimas-b c791b96
review: rename `of` to `fromHttpStatusCode`
dimas-b 933c0ac
review: add TaskState javadoc
dimas-b 3e39210
review: remove unused parameter
dimas-b eb8b528
review: move retry settings to EntitySnapshotTaskBehavior
dimas-b 6ee6aaa
review: report unhandled backend error codes
dimas-b bcfcab0
review: call backendExceptionMapper only if the is not mapped yet
dimas-b 53ad515
review: rename config to error-handling.throttled-retry-after
dimas-b fbc48dc
review: use `TooManyRequestsException` error `type for HTTP 429
dimas-b 5d3e076
review: support 429 in fromHttpStatusCode()
dimas-b bb39700
Move exception introspection code from IcebergErrorMapper to new Anal…
dimas-b a58391a
review: rename backendExceptionMapper()
dimas-b 90ac58e
review: update errorCode() javadoc
dimas-b c35c880
Remove `IOException` wrappers from `ObjectIO` impl.
dimas-b bbbf525
review: move throttled-retry-after to CatalogConfig
dimas-b a910364
review: move `retryable` flag to BackendErrorCode
dimas-b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
catalog/files/api/src/main/java/org/projectnessie/catalog/files/api/BackendErrorStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.catalog.files.api; | ||
|
||
import static org.projectnessie.catalog.files.api.BackendErrorCode.BAD_REQUEST; | ||
import static org.projectnessie.catalog.files.api.BackendErrorCode.FORBIDDEN; | ||
import static org.projectnessie.catalog.files.api.BackendErrorCode.NOT_FOUND; | ||
import static org.projectnessie.catalog.files.api.BackendErrorCode.THROTTLED; | ||
import static org.projectnessie.catalog.files.api.BackendErrorCode.UNAUTHORIZED; | ||
import static org.projectnessie.catalog.files.api.BackendErrorCode.UNKNOWN; | ||
|
||
import org.projectnessie.nessie.immutables.NessieImmutable; | ||
|
||
@NessieImmutable | ||
public interface BackendErrorStatus { | ||
BackendErrorCode statusCode(); | ||
|
||
Throwable cause(); | ||
|
||
static BackendErrorStatus of(BackendErrorCode statusCode, Throwable cause) { | ||
return ImmutableBackendErrorStatus.of(statusCode, cause); | ||
} | ||
|
||
static BackendErrorStatus fromHttpStatusCode(int httpStatusCode, Throwable cause) { | ||
switch (httpStatusCode) { | ||
dimas-b marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case 400: | ||
return BackendErrorStatus.of(BAD_REQUEST, cause); | ||
case 401: | ||
return BackendErrorStatus.of(UNAUTHORIZED, cause); | ||
case 403: | ||
return BackendErrorStatus.of(FORBIDDEN, cause); | ||
case 404: | ||
return BackendErrorStatus.of(NOT_FOUND, cause); | ||
case 429: | ||
return BackendErrorStatus.of(THROTTLED, cause); | ||
default: | ||
return BackendErrorStatus.of(UNKNOWN, cause); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...g/files/api/src/main/java/org/projectnessie/catalog/files/api/BackendExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.catalog.files.api; | ||
|
||
import com.google.errorprone.annotations.CanIgnoreReturnValue; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.projectnessie.nessie.immutables.NessieImmutable; | ||
|
||
@NessieImmutable | ||
public abstract class BackendExceptionMapper { | ||
|
||
protected abstract List<Analyzer> analyzers(); | ||
|
||
public static Builder builder() { | ||
return ImmutableBackendExceptionMapper.builder(); | ||
} | ||
|
||
public Optional<BackendErrorStatus> analyze(Throwable ex) { | ||
for (Throwable th = ex; th != null; th = th.getCause()) { | ||
for (Analyzer analyzer : analyzers()) { | ||
BackendErrorStatus status = analyzer.analyze(th); | ||
if (status != null) { | ||
return Optional.of(status); | ||
} | ||
} | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
public interface Analyzer { | ||
BackendErrorStatus analyze(Throwable th); | ||
} | ||
|
||
public interface Builder { | ||
@CanIgnoreReturnValue | ||
Builder addAnalyzer(Analyzer analyzer); | ||
|
||
BackendExceptionMapper build(); | ||
} | ||
} |
84 changes: 0 additions & 84 deletions
84
...iles/api/src/main/java/org/projectnessie/catalog/files/api/BackendThrottledException.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
catalog/files/api/src/main/java/org/projectnessie/catalog/files/api/RetryableException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make
UNKNOWN
retryable - we don't know what happened, so it can be retryable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know real
UNKNOWN
will end up in infinite retryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to add task deadlines in a follow-up PR and also fix #8860