Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Consider missing optional input/output artifacts with same name #3029

Merged
merged 2 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion test/e2e/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *FunctionalSuite) TestStopBehavior() {
assert.NoError(t, err)
assert.Contains(t, output, "workflow stop-terminate stopped")
}).
WaitForWorkflow(30 * time.Second).
WaitForWorkflow(45 * time.Second).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeFailed, status.Phase)
Expand Down Expand Up @@ -495,6 +495,18 @@ spec:
})
}

func (s *FunctionalSuite) TestSameInputOutputPathOptionalArtifact() {
s.Given().
Workflow("@testdata/same-input-output-path-optional.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(30 * time.Second).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})
}

func TestFunctionalSuite(t *testing.T) {
suite.Run(t, new(FunctionalSuite))
}
33 changes: 33 additions & 0 deletions test/e2e/testdata/same-input-output-path-optional.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: optional-input-output-artifact-same-location-
labels:
argo-e2e: true
spec:
entrypoint: plan
templates:
- name: plan
steps:
- - name: write
template: file
- - name: read
template: file
arguments:
artifacts:
- name: file
from: "{{steps.write.outputs.artifacts.file}}"
- name: file
inputs:
artifacts:
- name: file
path: /tmp/file1.txt
optional: true
container:
image: argoproj/argosay:v2
args: ["echo", "test", "/tmp/file1.txt"]
outputs:
artifacts:
- name: file
path: /tmp/file1.txt

6 changes: 6 additions & 0 deletions workflow/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ func (we *WorkflowExecutor) isBaseImagePath(path string) bool {
// next check if path overlaps with a shared input-artifact emptyDir mounted by argo
for _, inArt := range we.Template.Inputs.Artifacts {
if path == inArt.Path {
// The input artifact may have been optional and not supplied. If this is the case, the file won't exist on
// the input artifact volume. Since this function was called, we know that we want to use this path as an
// ourput artifact, so we should look for it in the base image path.
if inArt.Optional && !inArt.HasLocation() {
return true
}
return false
}
if strings.HasPrefix(path, inArt.Path+"/") {
Expand Down