Skip to content

Commit

Permalink
Stop failing if artifact file exists, but empty
Browse files Browse the repository at this point in the history
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 argoproj#1642
The problem was introduced in https://github.com/argoproj/argo/pulls/1247
  • Loading branch information
Ark-kun committed Oct 8, 2019
1 parent 7f385a6 commit abdcf02
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion util/file/fileutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
6 changes: 2 additions & 4 deletions util/file/fileutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""},
},
},
Expand Down
2 changes: 1 addition & 1 deletion workflow/executor/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit abdcf02

Please sign in to comment.