-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Snapshot only specific files for COPY #319
Conversation
Before GoogleContainerTools#289 was merged, when copying over directories for COPY kaniko would get a list of all files at the destination specified and add them to the list of files to be snapshotted. If the destination was root it would add all files. This worked because the snapshotter made sure the file had been changed before adding it to the layer. After GoogleContainerTools#289, we changed the logic to add all files snapshotted to a layer without checking if the files had been changed. This created the bug in got all the files at root and added them to the layer without checking if they had been changed. This change should fix this bug. Now, the CopyDir function returns a list of files it copied over and only those files are added to the list of files to be snapshotted. Should fix GoogleContainerTools#314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like this solution :D
pkg/util/fs_util.go
Outdated
@@ -155,21 +155,24 @@ func ChildDirInWhitelist(path, directory string) bool { | |||
return false | |||
} | |||
|
|||
func unTar(r io.Reader, dest string) error { | |||
// unTar returns a list of files extracted from the tar archive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to including in this docstring what the params r
and dest
are for (https://blog.golang.org/godoc-documenting-go-code) e.g. unTar returns a list of files that have been extracted from the tar archive at r to the path at dest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sure, just added it!
/bark |
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I'm sorry that that dog looks so suspicious |
I changed UnpackLocalTarArchive to return a list of files that were extracted, so that the list of snapshotted files for ADD is more accurate. Previously, we used to add all files in the extracted dir to be snapshotted, but this could result in preexisting files being snapshotted again.
Before #289 was merged, when copying over directories for COPY kaniko
would get a list of all files at the destination specified and add them
to the list of files to be snapshotted. If the destination was root it
would add all files. This worked because the snapshotter made sure the
file had been changed before adding it to the layer.
After #289, we changed the logic to add all files snapshotted to a layer
without checking if the files had been changed. This created the bug in which kaniko
got all the files at root and added them to the layer without checking
if they had been changed.
This change should fix this bug. Now, the CopyDir function returns a
list of files it copied over and only those files are added to the list
of files to be snapshotted.
I also added this change to the
UnpackLocalTarArchive
function in ADD, so that we only add specific files extracted from local tar archives to the list of snapshotted files.Should fix #314
Once #317 is implemented, this change will be tested by integration tests. Until then, I locally tested the Dockerfile in the bug and it seems to be working now.