Skip to content

Commit

Permalink
Avoid failure when submitting request quickly
Browse files Browse the repository at this point in the history
fix #6408

When submitting quickly, the creation may fail because the cache is not
updated. We can assume that is in progress, and the next reconcile will
handle it based on the actual situation.
  • Loading branch information
l-qing committed Mar 24, 2023
1 parent 63e1c02 commit 5060886
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/resolution/resource/crd_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned"
rrlisters "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1"
resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)
Expand Down Expand Up @@ -54,7 +55,11 @@ var _ Requester = &CRDRequester{}
func (r *CRDRequester) Submit(ctx context.Context, resolver ResolverName, req Request) (ResolvedResource, error) {
rr, _ := r.lister.ResolutionRequests(req.Namespace()).Get(req.Name())
if rr == nil {
if err := r.createResolutionRequest(ctx, resolver, req); err != nil {
if err := r.createResolutionRequest(ctx, resolver, req); err != nil &&
// When submitting quickly, the creation may fail because the cache is not updated.
// If the request already exists then we can assume that is in progress.
// The next reconcile will handle it based on the actual situation.
!apierrors.IsAlreadyExists(err) {
return nil, err
}
return nil, resolutioncommon.ErrRequestInProgress
Expand Down

0 comments on commit 5060886

Please sign in to comment.