Skip to content

Commit 8f37b1c

Browse files
Remove "bind" code path from diff
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 9139208 commit 8f37b1c

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

diff/windows/windows.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,10 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) {
321321
}
322322
mnt := mounts[0]
323323

324-
if mnt.Type != "windows-layer" && mnt.Type != "bind" {
324+
if mnt.Type != "windows-layer" {
325325
// This is a special case error. When this is received the diff service
326326
// will attempt the next differ in the chain which for Windows is the
327327
// lcow differ that we want.
328-
// TODO: Is there any situation where we actually wanted a "bind" mount to
329-
// fall through to the lcow differ?
330328
return "", nil, fmt.Errorf("windowsDiff does not support layer type %s: %w", mnt.Type, errdefs.ErrNotImplemented)
331329
}
332330

@@ -336,21 +334,16 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) {
336334
}
337335

338336
if mnt.ReadOnly() {
339-
if mnt.Type == "bind" && len(parentLayerPaths) != 0 {
340-
return "", nil, fmt.Errorf("unexpected bind-mount View with parents: %w", errdefs.ErrInvalidArgument)
341-
} else if mnt.Type == "bind" {
337+
if len(parentLayerPaths) == 0 {
342338
// rootfs.CreateDiff creates a new, empty View to diff against,
343339
// when diffing something with no parent.
344340
// This makes perfect sense for a walking Diff, but for WCOW,
345341
// we have to recognise this as "diff against nothing"
346342
return "", nil, nil
347-
} else if len(parentLayerPaths) == 0 {
348-
return "", nil, fmt.Errorf("unexpected windows-layer View with no parent: %w", errdefs.ErrInvalidArgument)
349343
}
350344
// Ignore the dummy sandbox.
351345
return parentLayerPaths[0], parentLayerPaths[1:], nil
352346
}
353-
354347
return mnt.Source, parentLayerPaths, nil
355348
}
356349

@@ -367,7 +360,7 @@ func mountPairToLayerStack(lower, upper []mount.Mount) ([]string, error) {
367360

368361
lowerLayer, lowerParentLayerPaths, err := mountsToLayerAndParents(lower)
369362
if errdefs.IsNotImplemented(err) {
370-
// Upper was a windows-layer or bind, lower is not. We can't handle that.
363+
// Upper was a windows-layer, lower is not. We can't handle that.
371364
return nil, fmt.Errorf("windowsDiff cannot diff a windows-layer against a non-windows-layer: %w", errdefs.ErrInvalidArgument)
372365
} else if err != nil {
373366
return nil, fmt.Errorf("Lower mount invalid: %w", err)

mount/mount_windows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ func (m *Mount) GetParentPaths() ([]string, error) {
148148

149149
// Unmount the mount at the provided path
150150
func Unmount(mount string, flags int) error {
151+
if _, err := os.Stat(mount); err != nil {
152+
if os.IsNotExist(err) {
153+
return nil
154+
}
155+
156+
return fmt.Errorf("failed to access mount point %s: %w", mount, err)
157+
}
158+
151159
mount = filepath.Clean(mount)
152160
adsFile := mount + ":" + sourceStreamName
153161
var layerPath string

snapshots/windows/windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
370370
}
371371

372372
if len(newSnapshot.ParentIDs) == 0 {
373-
// A parentless snapshot is just a bind-mount to a directory named
374-
// "Files". When committed, there'll be some post-processing to fill in the rest
373+
// A parentless snapshot a new base layer. Valid base layers must have a "Files" folder.
374+
// When committed, there'll be some post-processing to fill in the rest
375375
// of the metadata.
376376
filesDir := filepath.Join(snDir, "Files")
377377
if err := os.MkdirAll(filesDir, 0700); err != nil {

0 commit comments

Comments
 (0)