Skip to content

Commit 78b1e5b

Browse files
committed
pkg/resource: don't retry conflict errors
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent 0d8cbce commit 78b1e5b

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

pkg/connection/store/kubernetes/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func NewSecretStore(ctx context.Context, local client.Client, _ *tls.Config, cfg
6666
return &SecretStore{
6767
client: resource.ClientApplicator{
6868
Client: kube,
69-
Applicator: resource.NewApplicatorWithRetry(resource.NewAPIPatchingApplicator(kube), resource.IsAPIErrorWrapped, nil),
69+
Applicator: resource.NewApplicatorWithRetry(resource.NewAPIPatchingApplicator(kube), resource.IsNonConflictAPIErrorWrapped, nil),
7070
},
7171
defaultNamespace: cfg.DefaultScope,
7272
}, nil

pkg/reconciler/managed/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func NewAPISecretPublisher(c client.Client, ot runtime.ObjectTyper) *APISecretPu
9494
// backward compatibility with the original API of this function.
9595
return &APISecretPublisher{
9696
secret: resource.NewApplicatorWithRetry(resource.NewAPIPatchingApplicator(c),
97-
resource.IsAPIErrorWrapped, nil),
97+
resource.IsNonConflictAPIErrorWrapped, nil),
9898
typer: ot,
9999
}
100100
}

pkg/resource/api.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ func (a *APIUpdatingApplicator) Apply(ctx context.Context, o client.Object, ao .
198198
}
199199
}
200200

201-
// NOTE(hasheddan): we must set the resource version of the desired object
202-
// to that of the current or the update will always fail.
203-
m.SetResourceVersion(current.(metav1.Object).GetResourceVersion())
204201
return errors.Wrap(a.client.Update(ctx, m), "cannot update object")
205202
}
206203

pkg/resource/resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ func IsAPIErrorWrapped(err error) bool {
219219
return IsAPIError(errors.Cause(err))
220220
}
221221

222+
// IsNonConflictAPIErrorWrapped returns true if err is a non-conflict K8s API
223+
// error, or recursively wraps a K8s API error
224+
func IsNonConflictAPIErrorWrapped(err error) bool {
225+
cause := errors.Cause(err)
226+
return IsAPIError(cause) && !kerrors.IsConflict(cause)
227+
}
228+
222229
// IsConditionTrue returns if condition status is true
223230
func IsConditionTrue(c xpv1.Condition) bool {
224231
return c.Status == corev1.ConditionTrue

0 commit comments

Comments
 (0)