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

Fix bug in extracting hardlinks #284

Closed
wants to merge 9 commits into from

Conversation

priyawadhwa
Copy link
Collaborator

Should fix the issues brought up in #282

@@ -247,6 +287,15 @@ func checkWhiteouts(path string, whiteouts map[string]struct{}) bool {
return false
}

func checkSymlinks(path string, symlinks map[string]struct{}) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'm not sure why we need this one if we're checking the other stuff. Are you sure we need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, thanks for pointing that out! I'll remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we might actually need the symlink check, since we only want to specially hardlink at the end of extraction if the linked file exists but can't be hardlinked (which I think only happens if it's a symlink)

If a file was normally extracted in a previous layer than we can extract the file and create the hardlink normally

}
hardlinks[linkname] = &hardlink{
links: []*tar.Header{hdr},
reader: tr,
Copy link

Choose a reason for hiding this comment

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

Hmm, I'd be kinda surprised if saving off the tar reader here works later. Per the docs for tr.Next:

Next advances to the next entry in the tar archive. The Header.Size determines how many bytes can be read for the next file. Any remaining data in the current file is automatically discarded.

(emphasis mine)

One problem is that it's basically streaming through the archvie sequentially as it's downloading. It never buffers to disk or RAM, so I don't think you can go "back" to earlier entries in the archive. Tricky.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing this out, fixed.

@priyawadhwa priyawadhwa force-pushed the hardlink branch 5 times, most recently from e00f0d9 to 3dc172a Compare August 14, 2018 21:30
@priyawadhwa priyawadhwa changed the title [WIP] Fix bug in extracting hardlinks Fix bug in extracting hardlinks Aug 14, 2018
@priyawadhwa
Copy link
Collaborator Author

Woot tests are finally passing, PTAL!

@@ -55,6 +62,10 @@ func GetFSFromImage(root string, img v1.Image) error {

fs := map[string]struct{}{}
whiteouts := map[string]struct{}{}
hardlinks, err := retrieveHardlinks(layers)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think it would make sense to process each layer separately instead of doing them all at once? I think we already disallow hardlinks to cross layer boundaries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yah I think that would be better, I changed it to retrieve hardlinks as we process layers

@dlorenc
Copy link
Collaborator

dlorenc commented Aug 23, 2018

I think this needs a rebase now.

@priyawadhwa
Copy link
Collaborator Author

Done! :)

priyawadhwa pushed a commit to priyawadhwa/kaniko that referenced this pull request Aug 29, 2018
Extracting the layers of the filesystem in order will make it easier to
extract cached layers and deal with hardlinks, as mentioned in GoogleContainerTools#284

This PR implements extracting in order and adds an integration tests to
test the bug hardlinks error in GoogleContainerTools#284

It also fixes GoogleContainerTools#325
priyawadhwa pushed a commit to priyawadhwa/kaniko that referenced this pull request Aug 29, 2018
Extracting the layers of the filesystem in order will make it easier to
extract cached layers and deal with hardlinks, as mentioned in GoogleContainerTools#284

This PR implements extracting in order and adds an integration tests to
test the bug hardlinks error in GoogleContainerTools#284

It also fixes GoogleContainerTools#325
@priyawadhwa
Copy link
Collaborator Author

Closing, fixed by #326

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.

4 participants