cri: Don't use rel path for image volumes
Runc 1.1 throws a warning when using rel destination paths, and runc 1.2 is planning to thow an error (i.e. won't start the container). Let's just make this an abs path in the only place it might not be: the mounts created due to `VOLUME` directives in the Dockerfile. Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
This commit is contained in:
@@ -233,6 +233,7 @@ func TestVolumeMounts(t *testing.T) {
|
||||
testContainerRootDir := "test-container-root"
|
||||
for _, test := range []struct {
|
||||
desc string
|
||||
platform platforms.Platform
|
||||
criMounts []*runtime.Mount
|
||||
imageVolumes map[string]struct{}
|
||||
expectedMountDest []string
|
||||
@@ -280,6 +281,22 @@ func TestVolumeMounts(t *testing.T) {
|
||||
"/test-volume-2/",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "should make relative paths absolute on Linux",
|
||||
platform: platforms.Platform{OS: "linux"},
|
||||
imageVolumes: map[string]struct{}{
|
||||
"./test-volume-1": {},
|
||||
"C:/test-volume-2": {},
|
||||
"../../test-volume-3": {},
|
||||
"/abs/test-volume-4": {},
|
||||
},
|
||||
expectedMountDest: []string{
|
||||
"/test-volume-1",
|
||||
"/C:/test-volume-2",
|
||||
"/test-volume-3",
|
||||
"/abs/test-volume-4",
|
||||
},
|
||||
},
|
||||
} {
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
@@ -287,7 +304,7 @@ func TestVolumeMounts(t *testing.T) {
|
||||
Volumes: test.imageVolumes,
|
||||
}
|
||||
c := newTestCRIService()
|
||||
got := c.volumeMounts(testContainerRootDir, test.criMounts, config)
|
||||
got := c.volumeMounts(test.platform, testContainerRootDir, test.criMounts, config)
|
||||
assert.Len(t, got, len(test.expectedMountDest))
|
||||
for _, dest := range test.expectedMountDest {
|
||||
found := false
|
||||
|
||||
Reference in New Issue
Block a user