-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
ZIP containing single file cannot be used as an artifact due to errors in init container #984
Comments
To add to the confusion, the default tar on OSX does support zip archives, even when you don't supply |
My original summary is based on a misunderstanding but the fix is still correct.
The following terminal session shows examples run within the executor docker container: root@1122da224bd6:/tmp# echo content > file.txt
root@1122da224bd6:/tmp# zip file.zip file.txt
adding: file.txt (stored 0%)
root@1122da224bd6:/tmp# tar -czf file.tgz file.txt
root@1122da224bd6:/tmp# tar -tf file.tgz
file.txt
root@1122da224bd6:/tmp# tar -tf file.zip
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
root@1122da224bd6:/tmp# tar -tzf file.tgz
file.txt
root@1122da224bd6:/tmp# tar -tzf file.zip
root@1122da224bd6:/tmp# echo $?
0 |
`tar -tzf` will seemingly blindly filter with gzip which causes single-file ZIPs to be accidentally understood as tgz files. If we match such a tar we explode trying to untar as that call doesn't pass the option to uncompress and correctly spots that the file is not a tar. Closes argoproj#984.
`tar -tzf` will seemingly blindly filter with gzip which causes single-file ZIPs to be accidentally understood as tgz files. If we match such a tar we explode trying to untar as that call doesn't pass the option to uncompress and correctly spots that the file is not a tar. Closes #984.
A ZIP artifact containing a single file cannot be used as an Argo artifact. This hit me in production when a user trimmed down an input ZIP file. You get the following error from the init container:
It's misidentified as a tar by the
tar -tzf
test inexecutor.go
and so goes down the code path for extraction when it should have been handled as a simple file. This doesn't seem to be a reliable test for atar
file (the formats are very similar, so this is somewhat understandable).The
untar
call only passesxf
and so fails. Worryingly, if I runtar -zxf
on the test input below it does nothing and claims to succeed.This was with Argo 2.1.1 but the problematic test is also in master.
I think we should remove the
z
flag from the tar file test. Then it correctly notices that the ZIP isn't a tar. Compressed tars aren't supported at this point anyway, as theuntar
call doesn't pass the 'z' flag. A magic-number-based check might be another option. In future it might be worth considering explicit options for unpacking inputs.Test ZIP file
Test workflow:
The text was updated successfully, but these errors were encountered: