-
Notifications
You must be signed in to change notification settings - Fork 340
fix(orchestrator): pause upload retain retry #2993
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
jakubno
wants to merge
10
commits into
main
Choose a base branch
from
fix/orchestrator-pause-upload-retain-retry
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1877000
feat(orchestrator): add snapshot-upload-failed metric
jakubno 1c8dbc6
fix(orchestrator): retry pause snapshot uploads until durable
jakubno 5f7c767
fix(orchestrator): address PR review on upload retry
jakubno 8373fce
fix: lint
jakubno 244e838
feat(shared): add general-purpose retry.Do helper
jakubno a99316e
refactor(orchestrator): use shared retry.Do for snapshot upload retry
jakubno 39b3a4a
fix(orchestrator): drain in-flight snapshot uploads on shutdown
jakubno 4a0a030
feat(orchestrator): log snapshot-upload drain progress on shutdown
jakubno e301f91
clean up
jakubno 186614e
lint
jakubno 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
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
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,44 @@ | ||
| //go:build linux | ||
|
|
||
| package server | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/e2b-dev/infra/packages/orchestrator/pkg/sandbox/build" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/retry" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/storage" | ||
| ) | ||
|
|
||
| // defaultUploadRetryPolicy is the retry policy for pause-snapshot uploads: | ||
| // retry with a fresh per-attempt timeout under the total budget, with | ||
| // exponential backoff. | ||
| func defaultUploadRetryPolicy() retry.Policy { | ||
| return retry.Policy{ | ||
| TotalBudget: uploadTotalBudget, | ||
| AttemptTimeout: uploadTimeout, | ||
| InitialBackoff: uploadRetryInitialBackoff, | ||
| MaxBackoff: uploadRetryMaxBackoff, | ||
| Multiplier: uploadRetryBackoffMultiplier, | ||
| } | ||
| } | ||
|
|
||
| // isRetryableUploadErr classifies an upload failure. The default is RETRYABLE: | ||
| // a lost snapshot is unrecoverable and cascades to descendants, so a wasted | ||
| // retry is far cheaper than dropping a recoverable build. Only genuinely | ||
| // terminal conditions stop the loop. | ||
| func isRetryableUploadErr(err error) bool { | ||
| switch { | ||
| case errors.Is(err, build.NoDiffError{}): | ||
| return false // nothing to upload | ||
| case errors.Is(err, storage.ErrObjectNotExist): | ||
| return false // source vanished; retry cannot recover it | ||
| case errors.Is(err, context.Canceled): | ||
| return false // parent cancelled (shutdown) | ||
| default: | ||
| // Includes per-attempt context.DeadlineExceeded, GCS 401/503, rate | ||
| // limiting, and unknown errors — all worth retrying within the budget. | ||
| return true | ||
| } | ||
| } |
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,40 @@ | ||
| //go:build linux | ||
|
|
||
| package server | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
|
|
||
| "github.com/e2b-dev/infra/packages/orchestrator/pkg/sandbox/build" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/storage" | ||
| ) | ||
|
|
||
| func TestIsRetryableUploadErr(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| err error | ||
| retryable bool | ||
| }{ | ||
| {"no diff", build.NoDiffError{}, false}, | ||
| {"object not exist", storage.ErrObjectNotExist, false}, | ||
| {"object not exist wrapped", fmt.Errorf("load: %w", storage.ErrObjectNotExist), false}, | ||
| {"parent cancelled", context.Canceled, false}, | ||
| {"per-attempt deadline", context.DeadlineExceeded, true}, | ||
| {"gcs 503", errors.New("server error (503)"), true}, | ||
| {"unknown", errors.New("boom"), true}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| assert.Equal(t, tt.retryable, isRetryableUploadErr(tt.err)) | ||
| }) | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.