Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions internal/layers/lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"strings"

"github.com/Microsoft/go-winio/pkg/fs"
"github.com/containerd/containerd/api/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -77,7 +78,13 @@ func (lc *lcowLayersCloser) Release(ctx context.Context) (retErr error) {
// Returns the path at which the `rootfs` of the container can be accessed. Also, returns the path inside the
// UVM at which container scratch directory is located. Usually, this path is the path at which the container
// scratch VHD is mounted. However, in case of scratch sharing this is a directory under the UVM scratch.
func MountLCOWLayers(ctx context.Context, containerID string, layers *LCOWLayers, guestRoot string, vm *uvm.UtilityVM) (_, _ string, _ resources.ResourceCloser, err error) {
func MountLCOWLayers(
ctx context.Context,
containerID string,
layers *LCOWLayers,
guestRoot string,
vm *uvm.UtilityVM,
) (_, _ string, _ resources.ResourceCloser, err error) {
if vm == nil {
return "", "", nil, errors.New("MountLCOWLayers cannot be called for process-isolated containers")
}
Expand Down Expand Up @@ -114,7 +121,13 @@ func MountLCOWLayers(ctx context.Context, containerID string, layers *LCOWLayers
}

hostPath := layers.ScratchVHDPath
hostPath, err = filepath.EvalSymlinks(hostPath)
// For LCOW, we can reuse another container's scratch space (usually the sandbox container's).
//
// When sharing a scratch space, the `hostPath` will be a symlink to the sandbox.vhdx location to use.
// When not sharing a scratch space, `hostPath` will be the path to the sandbox.vhdx to use.
//
// Evaluate the symlink here (if there is one).
hostPath, err = fs.ResolvePath(hostPath)
if err != nil {
return "", "", nil, fmt.Errorf("failed to eval symlinks on scratch path: %w", err)
}
Expand Down
10 changes: 6 additions & 4 deletions test/functional/make_uvm_cim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ import (
"strings"
"testing"

"github.com/Microsoft/go-winio/pkg/fs"
"github.com/Microsoft/go-winio/pkg/guid"
"github.com/Microsoft/hcsshim/pkg/cimfs"
"github.com/Microsoft/hcsshim/pkg/extractuvm"
"github.com/google/go-containerregistry/pkg/crane"
v1 "github.com/google/go-containerregistry/pkg/v1"

"github.com/Microsoft/hcsshim/pkg/cimfs"
"github.com/Microsoft/hcsshim/pkg/extractuvm"
)

func compareFiles(t *testing.T, file1, file2 string) (bool, error) {
t.Helper()

file1, err := filepath.EvalSymlinks(file1)
file1, err := fs.ResolvePath(file1)
if err != nil {
return false, err
}

file2, err = filepath.EvalSymlinks(file2)
file2, err = fs.ResolvePath(file2)
if err != nil {
return false, err
}
Expand Down
Loading