Remove "bind" code path from diff
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
d373ebc4de
commit
6a5b4c9c24
@ -321,12 +321,10 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) {
|
|||||||
}
|
}
|
||||||
mnt := mounts[0]
|
mnt := mounts[0]
|
||||||
|
|
||||||
if mnt.Type != "windows-layer" && mnt.Type != "bind" {
|
if mnt.Type != "windows-layer" {
|
||||||
// This is a special case error. When this is received the diff service
|
// This is a special case error. When this is received the diff service
|
||||||
// will attempt the next differ in the chain which for Windows is the
|
// will attempt the next differ in the chain which for Windows is the
|
||||||
// lcow differ that we want.
|
// lcow differ that we want.
|
||||||
// TODO: Is there any situation where we actually wanted a "bind" mount to
|
|
||||||
// fall through to the lcow differ?
|
|
||||||
return "", nil, fmt.Errorf("windowsDiff does not support layer type %s: %w", mnt.Type, errdefs.ErrNotImplemented)
|
return "", nil, fmt.Errorf("windowsDiff does not support layer type %s: %w", mnt.Type, errdefs.ErrNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,21 +334,16 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if mnt.ReadOnly() {
|
if mnt.ReadOnly() {
|
||||||
if mnt.Type == "bind" && len(parentLayerPaths) != 0 {
|
if len(parentLayerPaths) == 0 {
|
||||||
return "", nil, fmt.Errorf("unexpected bind-mount View with parents: %w", errdefs.ErrInvalidArgument)
|
|
||||||
} else if mnt.Type == "bind" {
|
|
||||||
// rootfs.CreateDiff creates a new, empty View to diff against,
|
// rootfs.CreateDiff creates a new, empty View to diff against,
|
||||||
// when diffing something with no parent.
|
// when diffing something with no parent.
|
||||||
// This makes perfect sense for a walking Diff, but for WCOW,
|
// This makes perfect sense for a walking Diff, but for WCOW,
|
||||||
// we have to recognise this as "diff against nothing"
|
// we have to recognise this as "diff against nothing"
|
||||||
return "", nil, nil
|
return "", nil, nil
|
||||||
} else if len(parentLayerPaths) == 0 {
|
|
||||||
return "", nil, fmt.Errorf("unexpected windows-layer View with no parent: %w", errdefs.ErrInvalidArgument)
|
|
||||||
}
|
}
|
||||||
// Ignore the dummy sandbox.
|
// Ignore the dummy sandbox.
|
||||||
return parentLayerPaths[0], parentLayerPaths[1:], nil
|
return parentLayerPaths[0], parentLayerPaths[1:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return mnt.Source, parentLayerPaths, nil
|
return mnt.Source, parentLayerPaths, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +360,7 @@ func mountPairToLayerStack(lower, upper []mount.Mount) ([]string, error) {
|
|||||||
|
|
||||||
lowerLayer, lowerParentLayerPaths, err := mountsToLayerAndParents(lower)
|
lowerLayer, lowerParentLayerPaths, err := mountsToLayerAndParents(lower)
|
||||||
if errdefs.IsNotImplemented(err) {
|
if errdefs.IsNotImplemented(err) {
|
||||||
// Upper was a windows-layer or bind, lower is not. We can't handle that.
|
// Upper was a windows-layer, lower is not. We can't handle that.
|
||||||
return nil, fmt.Errorf("windowsDiff cannot diff a windows-layer against a non-windows-layer: %w", errdefs.ErrInvalidArgument)
|
return nil, fmt.Errorf("windowsDiff cannot diff a windows-layer against a non-windows-layer: %w", errdefs.ErrInvalidArgument)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, fmt.Errorf("Lower mount invalid: %w", err)
|
return nil, fmt.Errorf("Lower mount invalid: %w", err)
|
||||||
|
@ -148,6 +148,14 @@ func (m *Mount) GetParentPaths() ([]string, error) {
|
|||||||
|
|
||||||
// Unmount the mount at the provided path
|
// Unmount the mount at the provided path
|
||||||
func Unmount(mount string, flags int) error {
|
func Unmount(mount string, flags int) error {
|
||||||
|
if _, err := os.Stat(mount); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("failed to access mount point %s: %w", mount, err)
|
||||||
|
}
|
||||||
|
|
||||||
mount = filepath.Clean(mount)
|
mount = filepath.Clean(mount)
|
||||||
adsFile := mount + ":" + sourceStreamName
|
adsFile := mount + ":" + sourceStreamName
|
||||||
var layerPath string
|
var layerPath string
|
||||||
|
@ -370,8 +370,8 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(newSnapshot.ParentIDs) == 0 {
|
if len(newSnapshot.ParentIDs) == 0 {
|
||||||
// A parentless snapshot is just a bind-mount to a directory named
|
// A parentless snapshot a new base layer. Valid base layers must have a "Files" folder.
|
||||||
// "Files". When committed, there'll be some post-processing to fill in the rest
|
// When committed, there'll be some post-processing to fill in the rest
|
||||||
// of the metadata.
|
// of the metadata.
|
||||||
filesDir := filepath.Join(snDir, "Files")
|
filesDir := filepath.Join(snDir, "Files")
|
||||||
if err := os.MkdirAll(filesDir, 0700); err != nil {
|
if err := os.MkdirAll(filesDir, 0700); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user