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

Don't copy same files twice in copy integration tests #273

Merged
merged 2 commits into from
Aug 3, 2018

Conversation

bobcatfish
Copy link
Contributor

@bobcatfish bobcatfish commented Aug 2, 2018

The default hashing algorithm used by kaniko to determine if two files
are the same uses the files' mtime (the inode's modification time). It
turns out that this time is not always up to date, meaning that a file
could be modified but when you stat the file, the modification time may
not yet have been updated.

The copy integration tests were adding the same directory twice, the
second instance being to test copying a directory with a wilcard '*'.
Since the mtime is sometimes not updated, this caused kaniko to
sometimes think the files were the same, and sometimes think they were
different, varying the number of layers it created.

Now we will update those tests to use a completely different set of
files instead of copying the same files again.

In a later commit (which will hopefully fix #251) we will add a fix for
this and a new test case that will intentionally exercise this
functionality. In the meantime we'll prevent noisy test failures for
submitters.

Also fixed a bug I introduced into cmd.go 😅

@bobcatfish
Copy link
Contributor Author

    --- FAIL: TestLayers/test_layer_Dockerfile_test_copy_same_file (4.96s)
    	integration_test.go:220: Difference in number of layers in each image is 2 but should be 0. Image 1: Image: [gcr.io/kaniko-test/docker-dockerfile_test_copy_same_file] Digest: [ceedae45f627715ed0f4364ccbd2d9bb2636a4a3f4f163a212abe385b3157088] Number of Layers: [43], Image 2: Image: [gcr.io/kaniko-test/kaniko-dockerfile_test_copy_same_file] Digest: [75124d7c203dc626435e8d7e4eb949e8d5f93e857560040dcb62e4cd54ef5459] Number of Layers: [41]

howling NOOOOOO

@bobcatfish
Copy link
Contributor Author

This might be https://linux.die.net/man/8/sync:

On Linux, sync is only guaranteed to schedule the dirty blocks for writing; it can actually take a short time before all the blocks are finally written.

☹️

@bobcatfish bobcatfish force-pushed the layer_failure branch 2 times, most recently from f0febb5 to b614934 Compare August 2, 2018 23:49
pkg/util/util.go Outdated
@@ -45,6 +46,7 @@ func Hasher() func(string) (string, error) {
if err != nil {
return "", err
}
logrus.Infof("File %s Mode %s ModTime %s IsRegular %s\n", p, fi.Mode().String(), fi.ModTime().String(), fi.Mode().IsRegular())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to remove this or make it logrus.Debugf since info on every file every time we snapshot could make it difficult to parse through logs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I don't want to commit this, I just added this so I could see what was happening with these latest failures 😇

@bobcatfish bobcatfish changed the title Sync filesystem before snapshotting so mtime can be relied on Don't copy same files twice in copy integration tests Aug 3, 2018
The default hashing algorithm used by kaniko to determine if two files
are the same uses the files' mtime (the inode's modification time). It
turns out that this time is not always up to date, meaning that a file
could be modified but when you stat the file, the modification time may
not yet have been updated.

The copy integration tests were adding the same directory twice, the
second instance being to test copying a directory with a wilcard '*'.
Since the mtime is sometimes not updated, this caused kaniko to
sometimes think the files were the same, and sometimes think they were
different, varying the number of layers it created.

Now we will update those tests to use a completely different set of
files instead of copying the same files again.

In a later commit (which will hopefully fix GoogleContainerTools#251) we will add a fix for
this and a new test case that will intentionally exercise this
functionality. In the meantime we'll prevent noisy test failures for
submitters.
I _thought_ I was running into cases where Kaniko would fail to build
but the test would continue... looks like it was a bug I added!
@bobcatfish
Copy link
Contributor Author

Updated this PR to just stop the tests from flaking while we work on a fix for #251.

Copy link
Collaborator

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woot!

@priyawadhwa priyawadhwa merged commit 53b5fb4 into GoogleContainerTools:master Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Number of layers inconsistent with kaniko builds that copy/copy the same files multiple times
2 participants