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

Snapshot only specific files for COPY #319

Merged
merged 2 commits into from
Aug 27, 2018

Conversation

priyawadhwa
Copy link
Collaborator

@priyawadhwa priyawadhwa commented Aug 27, 2018

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.

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
Copy link
Contributor

@bobcatfish bobcatfish left a 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

@@ -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
Copy link
Contributor

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

Copy link
Collaborator Author

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!

@bobcatfish
Copy link
Contributor

/bark

@container-tools-bot
Copy link
Collaborator

@bobcatfish: dog image

In response to this:

/bark

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.

@bobcatfish
Copy link
Contributor

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image sizes increased dramatically since merging #289
3 participants