Skip to content

Commit

Permalink
fix: prevent backoff when retryStrategy.limit has been reached. Fixes #…
Browse files Browse the repository at this point in the history
…7588 (#8090)

Signed-off-by: Rohan Kumar <rohankmr414@gmail.com>
  • Loading branch information
rohankmr414 authored and alexec committed May 3, 2022
1 parent c17f8c7 commit ba8c600
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions test/e2e/retry_test.go
@@ -0,0 +1,53 @@
//go:build functional
// +build functional

package e2e

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/test/e2e/fixtures"
)

type RetryTestSuite struct {
fixtures.E2ESuite
}

func (s *RetryTestSuite) TestRetryLimit() {
s.Given().
Workflow(`
metadata:
generateName: test-backoff-
spec:
entrypoint: main
templates:
- name: main
retryStrategy:
limit: 0
backoff:
duration: 2s
factor: 2
maxDuration: 5m
container:
name: main
image: 'argoproj/argosay:v2'
args: [ exit, "1" ]
`).
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowPhase("Failed"), status.Phase)
assert.Equal(t, "No more retries left", status.Message)
})
}

func TestRetrySuite(t *testing.T) {
suite.Run(t, new(RetryTestSuite))
}
2 changes: 1 addition & 1 deletion workflow/controller/operator.go
Expand Up @@ -909,7 +909,7 @@ func (woc *wfOperationCtx) processNodeRetries(node *wfv1.NodeStatus, retryStrate
}

// See if we have waited past the deadline
if time.Now().Before(waitingDeadline) {
if time.Now().Before(waitingDeadline) && int32(len(node.Children)) <= retryStrategy.Limit.IntVal {
woc.requeueAfter(timeToWait)
retryMessage := fmt.Sprintf("Backoff for %s", humanize.Duration(timeToWait))
return woc.markNodePhase(node.Name, node.Phase, retryMessage), false, nil
Expand Down

0 comments on commit ba8c600

Please sign in to comment.