forked from kubernetes/apiserver
-
Notifications
You must be signed in to change notification settings - Fork 30
OCPBUGS-61754: UPSTREAM: <carry> Add retries for GetCurrentResourceVersion. #72
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
p0lyn0mial
merged 1 commit into
openshift:openshift-apiserver-4.20-kubernetes-1.33
from
benluddy:openshift-apiserver-4.20-kubernetes-1.33-etcd-retrier-getcurrentresourceversion
Sep 17, 2025
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,29 +26,59 @@ var DefaultRetry = wait.Backoff{ | |
| } | ||
|
|
||
| type retryClient struct { | ||
| // embed because we only want to override a few states | ||
| storage.Interface | ||
| // All methods of storage.Interface are implemented directly on *retryClient, even when they | ||
| // are purely passthroughs to the delegate. During a rebase, consider whether or not it is | ||
| // safe and appropriate for a new method added to the method set of storage.Interface to | ||
| // perform retries. | ||
| delegate storage.Interface | ||
| } | ||
|
|
||
| func (c *retryClient) Count(key string) (int64, error) { | ||
| return c.delegate.Count(key) | ||
| } | ||
|
|
||
| func (c *retryClient) ReadinessCheck() error { | ||
| return c.delegate.ReadinessCheck() | ||
| } | ||
|
|
||
| func (c *retryClient) RequestWatchProgress(ctx context.Context) error { | ||
| return c.delegate.RequestWatchProgress(ctx) | ||
| } | ||
|
|
||
| func (c *retryClient) Versioner() storage.Versioner { | ||
| return c.delegate.Versioner() | ||
| } | ||
|
|
||
| // New returns an etcd3 implementation of storage.Interface. | ||
| func NewRetryingEtcdStorage(delegate storage.Interface) storage.Interface { | ||
| return &retryClient{Interface: delegate} | ||
| return &retryClient{delegate: delegate} | ||
| } | ||
|
|
||
| func (c *retryClient) GetCurrentResourceVersion(ctx context.Context) (uint64, error) { | ||
| var ( | ||
| rv uint64 | ||
| err error | ||
| ) | ||
| return rv, OnError(ctx, DefaultRetry, IsRetriableErrorOnRead, func() error { | ||
| rv, err = c.delegate.GetCurrentResourceVersion(ctx) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is a read operation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the err will always be propagated. |
||
| return err | ||
| }) | ||
| } | ||
|
|
||
| // Create adds a new object at a key unless it already exists. 'ttl' is time-to-live | ||
| // in seconds (0 means forever). If no error is returned and out is not nil, out will be | ||
| // set to the read value from database. | ||
| func (c *retryClient) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error { | ||
| return OnError(ctx, DefaultRetry, IsRetriableErrorOnWrite, func() error { | ||
| return c.Interface.Create(ctx, key, obj, out, ttl) | ||
| return c.delegate.Create(ctx, key, obj, out, ttl) | ||
| }) | ||
| } | ||
|
|
||
| // Delete removes the specified key and returns the value that existed at that spot. | ||
| // If key didn't exist, it will return NotFound storage error. | ||
| func (c *retryClient) Delete(ctx context.Context, key string, out runtime.Object, preconditions *storage.Preconditions, validateDeletion storage.ValidateObjectFunc, cachedExistingObject runtime.Object, opts storage.DeleteOptions) error { | ||
| return OnError(ctx, DefaultRetry, IsRetriableErrorOnWrite, func() error { | ||
| return c.Interface.Delete(ctx, key, out, preconditions, validateDeletion, cachedExistingObject, opts) | ||
| return c.delegate.Delete(ctx, key, out, preconditions, validateDeletion, cachedExistingObject, opts) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -63,7 +93,7 @@ func (c *retryClient) Watch(ctx context.Context, key string, opts storage.ListOp | |
| var ret watch.Interface | ||
| err := OnError(ctx, DefaultRetry, IsRetriableErrorOnRead, func() error { | ||
| var innerErr error | ||
| ret, innerErr = c.Interface.Watch(ctx, key, opts) | ||
| ret, innerErr = c.delegate.Watch(ctx, key, opts) | ||
| return innerErr | ||
| }) | ||
| return ret, err | ||
|
|
@@ -76,7 +106,7 @@ func (c *retryClient) Watch(ctx context.Context, key string, opts storage.ListOp | |
| // match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'. | ||
| func (c *retryClient) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error { | ||
| return OnError(ctx, DefaultRetry, IsRetriableErrorOnRead, func() error { | ||
| return c.Interface.Get(ctx, key, opts, objPtr) | ||
| return c.delegate.Get(ctx, key, opts, objPtr) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -88,7 +118,7 @@ func (c *retryClient) Get(ctx context.Context, key string, opts storage.GetOptio | |
| // match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'. | ||
| func (c *retryClient) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error { | ||
| return OnError(ctx, DefaultRetry, IsRetriableErrorOnRead, func() error { | ||
| return c.Interface.GetList(ctx, key, opts, listObj) | ||
| return c.delegate.GetList(ctx, key, opts, listObj) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -129,7 +159,7 @@ func (c *retryClient) GetList(ctx context.Context, key string, opts storage.List | |
| func (c *retryClient) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, | ||
| preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error { | ||
| return OnError(ctx, DefaultRetry, IsRetriableErrorOnWrite, func() error { | ||
| return c.Interface.GuaranteedUpdate(ctx, key, destination, ignoreNotFound, preconditions, tryUpdate, cachedExistingObject) | ||
| return c.delegate.GuaranteedUpdate(ctx, key, destination, ignoreNotFound, preconditions, tryUpdate, cachedExistingObject) | ||
| }) | ||
| } | ||
|
|
||
|
|
||
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.
yeah, good call. thanks.