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

Stop failing if artifact file exists, but empty #1653

Merged
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
Stop failing if artifact file exists, but empty
Empty output artifacts are a valid and desired use case. (Think of `grep` or any other filtering program where one of the outputs can be empty.)
Argo failing on empty outputs was a pretty bad surprise for us.

Fixes #1642
The problem was introduced in https://github.com/argoproj/argo/pulls/1247
Ark-kun committed Oct 8, 2019
commit abdcf02c166af7878b1ac4c5faf3fa1ab34196a6
2 changes: 1 addition & 1 deletion util/file/fileutil.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ func ExistsInTar(sourcePath string, tarReader TarReader) bool {
if hdr.FileInfo().IsDir() && strings.Contains(sourcePath, strings.Trim(hdr.Name, "/")) {
return true
}
if strings.Contains(sourcePath, hdr.Name) && hdr.Size > 0 {
if strings.Contains(sourcePath, hdr.Name) {
return true
}
}
6 changes: 2 additions & 4 deletions util/file/fileutil_test.go
Original file line number Diff line number Diff line change
@@ -97,16 +97,14 @@ func TestExistsInTar(t *testing.T) {
},
},
{
sourcePath: "/empty.txt", expected: false,
sourcePath: "/empty.txt", expected: true,
files: []fakeFile{
// fails because empty.txt is empty
{name: "empty.txt", body: ""},
},
},
{
sourcePath: "/tmp/empty.txt", expected: false,
sourcePath: "/tmp/empty.txt", expected: true,
files: []fakeFile{
// fails because empty.txt is empty
{name: "empty.txt", body: ""},
},
},
2 changes: 1 addition & 1 deletion workflow/executor/docker/docker.go
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ func (d *DockerExecutor) CopyFile(containerID string, sourcePath string, destPat
return err
}
if !file.ExistsInTar(sourcePath, tar.NewReader(gzipReader)) {
errMsg := fmt.Sprintf("path %s does not exist (or %s is empty) in archive %s", sourcePath, sourcePath, destPath)
errMsg := fmt.Sprintf("path %s does not exist in archive %s", sourcePath, destPath)
log.Warn(errMsg)
return errors.Errorf(errors.CodeNotFound, errMsg)
}