Skip to content

Commit

Permalink
fix(executor): Correctly surface error when resource is deleted durin…
Browse files Browse the repository at this point in the history
…g status checking (argoproj#5675)
  • Loading branch information
terrytangyuan committed Apr 15, 2021
1 parent eab122b commit 24ac725
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions workflow/executor/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
apierr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -210,6 +211,10 @@ func (we *WorkflowExecutor) checkResourceState(ctx context.Context, selfLink str
return true, errors.Errorf(errors.CodeNotFound, "The error is detected to be transient: %v. Retrying...", err)
}
if err != nil {
err = errors.Cause(err)
if apierr.IsNotFound(err) {
return false, errors.Errorf(errors.CodeNotFound, "The resource has been deleted while its status was still being checked. Will not be retried: %v", err)
}
return false, err
}

Expand All @@ -220,10 +225,6 @@ func (we *WorkflowExecutor) checkResourceState(ctx context.Context, selfLink str
}
jsonString := string(jsonBytes)
log.Info(jsonString)

if strings.Contains(jsonString, "NotFound") {
return false, errors.Errorf(errors.CodeNotFound, "The resource has been deleted. Will not be retried.")
}
if !gjson.Valid(jsonString) {
return false, errors.Errorf(errors.CodeNotFound, "Encountered invalid JSON response when checking resource status. Will not be retried: %q", jsonString)
}
Expand Down

0 comments on commit 24ac725

Please sign in to comment.