Skip to content

Commit

Permalink
fix: PVC in wf.status should be reset when retrying workflow (#10685)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan authored Mar 17, 2023
1 parent 9f1b68d commit ec85683
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,30 @@ func (s *CLISuite) TestWorkflowRetryNestedDag() {
})
}

func (s *CLISuite) TestWorkflowRetryWithRecreatedPVC() {
s.Given().
Workflow("@testdata/retry-with-recreated-pvc-test.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
RunCli([]string{"retry", "retry-with-recreated-pvc"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err, output) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
}
}).
When().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeFailed, status.Nodes.FindByDisplayName("print").Phase)
// This step is failed intentionally to allow retry. The error message is not related to PVC that is deleted
// previously since it is re-created during retry.
assert.Equal(t, "Error (exit code 1)", status.Nodes.FindByDisplayName("print").Message)
})
}

func (s *CLISuite) TestWorkflowStop() {
s.Given().
Workflow("@smoke/basic.yaml").
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/testdata/retry-with-recreated-pvc-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: retry-with-recreated-pvc
spec:
volumeClaimGC:
strategy: OnWorkflowCompletion
entrypoint: volumes-pvc-example
volumeClaimTemplates:
- metadata:
name: workdir
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi

templates:
- name: volumes-pvc-example
steps:
- - name: generate
template: whalesay
- - name: print
template: print-message

- name: whalesay
container:
image: argoproj/argosay:v2
command: [sh, -c]
args: ["echo generating message in volume; cowsay hello world | tee /mnt/vol/hello_world.txt"]
volumeMounts:
- name: workdir
mountPath: /mnt/vol

- name: print-message
container:
image: argoproj/argosay:v2
command: [sh, -c]
args: ["exit 1"]
volumeMounts:
- name: workdir
mountPath: /mnt/vol
1 change: 1 addition & 0 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSucce
newWF.Status.StartedAt = metav1.Time{Time: time.Now().UTC()}
newWF.Status.FinishedAt = metav1.Time{}
newWF.Spec.Shutdown = ""
newWF.Status.PersistentVolumeClaims = []apiv1.Volume{}
if newWF.Spec.ActiveDeadlineSeconds != nil && *newWF.Spec.ActiveDeadlineSeconds == 0 {
// if it was terminated, unset the deadline
newWF.Spec.ActiveDeadlineSeconds = nil
Expand Down

0 comments on commit ec85683

Please sign in to comment.