-
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
Extract filesystem in order rather than in reverse #326
Extract filesystem in order rather than in reverse #326
Conversation
Extracting the layers of the filesystem in order will make it easier to extract cached layers and deal with hardlinks. This PR implements extracting in order and adds an integration tests to make sure hardlinks are extracted properly. It also fixes two bugs I found when extracting symlinks: 1. We'd get a "file exists" error when trying to symlink to an existing file with a whiteout later in the layer tarball 2. We'd get a "file exists" error when trying to create a symlink from a file that was created in a prior layer (perhaps as a regular file or as a symlink pointing to someting else) To fix both of these, we resolve all symlinks in a layer at the end. I also added logic to delete any existing paths before creating the symlink.
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.
Just one question
pkg/util/fs_util.go
Outdated
@@ -107,13 +98,18 @@ func GetFSFromImage(root string, img v1.Image) error { | |||
logrus.Debugf("skipping symlink from %s to %s because %s is whitelisted", hdr.Linkname, path, hdr.Linkname) | |||
continue | |||
} | |||
symlinks = append(symlinks, hdr) |
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.
Why do we need to special case symlinks here?
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.
It seems like we could just create them during the pass.
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.
You're right! I misunderstood how a layer would be formed if a file was removed and then symlinked in the same layer -- fixed it now.
Extracting the layers of the filesystem in order will make it easier to
extract cached layers and deal with hardlinks.
This PR implements extracting in order and adds an integration tests to
make sure hardlinks are extracted properly.
It also fixes two bugs I found when extracting symlinks:
file with a whiteout later in the layer tarball
file that was created in a prior layer (perhaps as a regular file or as
a symlink pointing to someting else)
To fix both of these, we resolve all symlinks in a layer at the end. I
also added logic to delete any existing paths before creating the
symlink.