Skip to content

Commit fa9f877

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

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
@@ -74,7 +74,7 @@ func NewAPISecretPublisher(c client.Client, ot runtime.ObjectTyper) *APISecretPu
7474
// backward compatibility with the original API of this function.
7575
return &APISecretPublisher{
7676
secret: resource.NewApplicatorWithRetry(resource.NewAPIPatchingApplicator(c),
77-
resource.IsAPIErrorWrapped, nil),
77+
resource.IsNonConflictAPIErrorWrapped, nil),
7878
typer: ot,
7979
}
8080
}

pkg/resource/api.go

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

130-
// NOTE(hasheddan): we must set the resource version of the desired object
131-
// to that of the current or the update will always fail.
132-
m.SetResourceVersion(current.(metav1.Object).GetResourceVersion())
133130
return errors.Wrap(a.client.Update(ctx, m), "cannot update object")
134131
}
135132

pkg/resource/resource.go

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

193+
// IsNonConflictAPIErrorWrapped returns true if err is a non-conflict K8s API
194+
// error, or recursively wraps a K8s API error
195+
func IsNonConflictAPIErrorWrapped(err error) bool {
196+
cause := errors.Cause(err)
197+
return IsAPIError(cause) && !kerrors.IsConflict(cause)
198+
}
199+
193200
// IsConditionTrue returns if condition status is true
194201
func IsConditionTrue(c xpv1.Condition) bool {
195202
return c.Status == corev1.ConditionTrue

0 commit comments

Comments
 (0)