forked from loft-sh/devpod
-
Notifications
You must be signed in to change notification settings - Fork 25
refactor(agent): replace custom retry logic with Kubernetes backoff strategy #446
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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.
🧩 Analysis chain
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 488
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 70
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 1037
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 1150
🌐 Web query:
client-go v0.35.0 retry.OnError context handling deadline💡 Result:
In client-go v0.35.0, the
k8s.io/client-go/util/retrypackage does not provideretry.OnError(it only exposes conflict-focused helpers likeRetryOnConflict). (pkg.go.dev)So there is no context/deadline handling for
retry.OnErrorin client-go v0.35.0, because that function isn’t part of that module/version.If your goal is “retry but stop when
ctxis canceled / its deadline expires”, usewait.ExponentialBackoffWithContext(ctx, backoff, condition), which explicitly returns when the context is canceled or hits its deadline. (pkg.go.dev)Citations:
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 141
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 42
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 42
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 42
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 995
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 401
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 597
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 456
🌐 Web query:
k8s.io/client-go/util/retry OnError function signature v0.35.0💡 Result:
In
k8s.io/client-go/util/retryv0.35.0,OnErrorhas this signature:(Some docs/name variants call the 2nd arg
retriable, but the type/signature is the same.) [1][2]🌐 Web query:
k8s.io/apimachinery/pkg/util/wait ExponentialBackoff context support💡 Result:
wait.ExponentialBackoffdoes not take acontext.Context(it usesConditionFunc func() (bool, error)), so it can’t be directly canceled via context. (pkg.go.dev)For context cancellation/deadlines, use
wait.ExponentialBackoffWithContext:func ExponentialBackoffWithContext(ctx context.Context, backoff Backoff, condition ConditionWithContextFunc) error(pkg.go.dev)ctxis canceled / hits deadline, if the condition returns an error, or when attempts are exhausted (ErrWaitTimeout). (pkg.go.dev)Example:
Citations:
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 2159
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 323
🏁 Script executed:
Repository: skevetter/devpod
Length of output: 558
Overall retry can exceed
InjectOptions.Timeout.Timeoutis documented as the maximum duration to wait for injection completion, but the retry loop runs for a fixed 30 steps regardless of elapsed time. Theopts.Ctx.Err()check in the callback is insufficient because context expiration is only checked between retries, not during the backoff delays themselves. With the current backoff configuration (~27 minutes total sleep), injection can run far longer than the documented timeout (default 5 minutes). Bind retries to a timeout-aware context so that the overall time is actually capped by the timeout:🛠️ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents