This fixes a bug in the interaction between volumes in base images (#555)

and our snapshot optimizations.

If a previous base image has a volume, the directory is added to the
list of files to snapshot. That directory may not actually exist in the image.
This commit is contained in:
dlorenc
2019-02-08 14:40:37 -06:00
committed by GitHub
parent e14b660947
commit 9047ccf7cc
4 changed files with 19 additions and 14 deletions
+11 -5
View File
@@ -64,6 +64,8 @@ var initialWhitelist = []WhitelistEntry{
var whitelist = initialWhitelist
var volumes = []string{}
var excluded []string
// GetFSFromImage extracts the layers of img to root
@@ -308,6 +310,7 @@ func CheckWhitelist(path string) (bool, error) {
return true, nil
}
}
return false, nil
}
@@ -331,6 +334,7 @@ func checkWhitelistRoot(root string) bool {
// From: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
func DetectFilesystemWhitelist(path string) error {
whitelist = initialWhitelist
volumes = []string{}
f, err := os.Open(path)
if err != nil {
return err
@@ -443,16 +447,14 @@ func CreateFile(path string, reader io.Reader, perm os.FileMode, uid uint32, gid
return dest.Chown(int(uid), int(gid))
}
// AddVolumePathToWhitelist adds the given path to the whitelist with
// PrefixMatchOnly set to true. Snapshotting will ignore paths prefixed
// with the volume, but the volume itself will not be ignored.
func AddVolumePathToWhitelist(path string) error {
// AddVolumePath adds the given path to the volume whitelist.
func AddVolumePathToWhitelist(path string) {
logrus.Infof("adding volume %s to whitelist", path)
whitelist = append(whitelist, WhitelistEntry{
Path: path,
PrefixMatchOnly: true,
})
return nil
volumes = append(volumes, path)
}
// DownloadFileToDest downloads the file at rawurl to the given dest for the ADD command
@@ -620,3 +622,7 @@ func HasFilepathPrefix(path, prefix string, prefixMatchOnly bool) bool {
}
return true
}
func Volumes() []string {
return volumes
}