-
Notifications
You must be signed in to change notification settings - Fork 593
feat: prevent retries when terminal error happens #4258
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
Open
ogzhanolguncu
wants to merge
11
commits into
main
Choose a base branch
from
deploy-logs/error-handling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9d92c25
feat: update ch schema
ogzhanolguncu 262e40d
chore: update migration
ogzhanolguncu 9e7021a
chore: get rid of old migration file
ogzhanolguncu 5f45c75
feat: update ch schema
ogzhanolguncu f5fec6e
feat: add log parsing
ogzhanolguncu 98f8b23
feat: prevent retries when terminal error happens
ogzhanolguncu 4046eef
fix: update error list
ogzhanolguncu f6e3c13
refactor: fix ordering
ogzhanolguncu 95de06b
Merge branch 'main' into deploy-logs/error-handling
ogzhanolguncu 266963b
refactor: remove sorting
ogzhanolguncu ec59a17
Merge branch 'main' into deploy-logs/error-handling
Flo4604 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 hidden or 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 hidden or 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,51 @@ | ||
| package depot | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "connectrpc.com/connect" | ||
| restate "github.com/restatedev/sdk-go" | ||
| ) | ||
|
|
||
| // These patterns indicate terminal errors that should NOT be retried | ||
| var terminalErrorPatterns = []string{ | ||
| "exit code:", // Usually terminal errors thrown by upstream providers contains that. | ||
| "failed to solve", // This happens when it fails to fetch an image or build from source | ||
| "failed to compute cache key", // Broken dockerfile | ||
| "no such file or directory", // This happens when user passes wrong dokcerfile path | ||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "internal error", // This is mostly thrown by depot. It means something is wrong on their end. | ||
| "permission denied", // This is on us we either pass wrong depot token or organization/project mismatch | ||
| "unauthenticated", // Wrong depot token | ||
| "unknown key: platforms", // Depot only allows "us-east-1" and "eu-central-1" | ||
| "dockerfile parse error on line", | ||
| } | ||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // isTerminalBuildError returns true if the error is terminal and Restate should NOT retry. | ||
| // In some cases such as broken dockerfile, internal error, wrong dockerfile path, there is no reason to keep retrying. | ||
| // We could retry, but those would pollute the CH logs | ||
| func isTerminalBuildError(err error) bool { | ||
| if err == nil { | ||
| return false | ||
| } | ||
|
|
||
| errMsg := strings.ToLower(err.Error()) | ||
|
|
||
| for _, pattern := range terminalErrorPatterns { | ||
| if strings.Contains(errMsg, pattern) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| func wrapBuildError(err error, code connect.Code, msg string) error { | ||
| wrapped := fmt.Errorf("%s: %w", msg, err) | ||
|
|
||
| if isTerminalBuildError(err) { | ||
| return restate.TerminalError(wrapped) | ||
| } | ||
|
|
||
| return connect.NewError(code, wrapped) | ||
| } | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.