Merge pull request #1337 from Random-Liu/clean-mount-path
[WCOW] Clean mount path for windows
This commit is contained in:
commit
0dcaf6e987
@ -77,8 +77,7 @@ func WithWindowsMounts(osi osinterface.OS, config *runtime.ContainerConfig, extr
|
|||||||
sort.Sort(orderedMounts(mounts))
|
sort.Sort(orderedMounts(mounts))
|
||||||
|
|
||||||
// Copy all mounts from default mounts, except for
|
// Copy all mounts from default mounts, except for
|
||||||
// - mounts overridden by supplied mount;
|
// mounts overridden by supplied mount;
|
||||||
// - all mounts under /dev if a supplied /dev is present.
|
|
||||||
mountSet := make(map[string]struct{})
|
mountSet := make(map[string]struct{})
|
||||||
for _, m := range mounts {
|
for _, m := range mounts {
|
||||||
mountSet[filepath.Clean(m.ContainerPath)] = struct{}{}
|
mountSet[filepath.Clean(m.ContainerPath)] = struct{}{}
|
||||||
@ -123,8 +122,9 @@ func WithWindowsMounts(osi osinterface.OS, config *runtime.ContainerConfig, extr
|
|||||||
options = append(options, "rw")
|
options = append(options, "rw")
|
||||||
}
|
}
|
||||||
s.Mounts = append(s.Mounts, runtimespec.Mount{
|
s.Mounts = append(s.Mounts, runtimespec.Mount{
|
||||||
Source: src,
|
// hcsshim requires clean path, especially '/' -> '\'.
|
||||||
Destination: dst,
|
Source: filepath.Clean(src),
|
||||||
|
Destination: filepath.Clean(dst),
|
||||||
Options: options,
|
Options: options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -140,3 +140,22 @@ func TestContainerWindowsNetworkNamespace(t *testing.T) {
|
|||||||
assert.NotNil(t, spec.Windows.Network)
|
assert.NotNil(t, spec.Windows.Network)
|
||||||
assert.Equal(t, nsPath, spec.Windows.Network.NetworkNamespace)
|
assert.Equal(t, nsPath, spec.Windows.Network.NetworkNamespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMountCleanPath(t *testing.T) {
|
||||||
|
testID := "test-id"
|
||||||
|
testSandboxID := "sandbox-id"
|
||||||
|
testPid := uint32(1234)
|
||||||
|
nsPath := "test-cni"
|
||||||
|
c := newTestCRIService()
|
||||||
|
|
||||||
|
containerConfig, sandboxConfig, imageConfig, specCheck := getCreateContainerTestData()
|
||||||
|
containerConfig.Mounts = append(containerConfig.Mounts, &runtime.Mount{
|
||||||
|
ContainerPath: "c:/test/container-path",
|
||||||
|
HostPath: "c:/test/host-path",
|
||||||
|
})
|
||||||
|
spec, err := c.containerSpec(testID, testSandboxID, testPid, nsPath, containerConfig, sandboxConfig, imageConfig, nil, config.Runtime{})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotNil(t, spec)
|
||||||
|
specCheck(t, testID, testSandboxID, testPid, spec)
|
||||||
|
checkMount(t, spec.Mounts, "c:\\test\\host-path", "c:\\test\\container-path", "", []string{"rw"}, nil)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user