mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Handle any volume type, not only tmpfs (#42)
This commit is contained in:
committed by
Lantao Liu
parent
f299b553af
commit
67745b88e0
@@ -117,10 +117,6 @@ func UpdateVolumeAnnotations(bundle string, s *specs.Spec) error {
|
||||
if volumeFieldName(k) != "type" {
|
||||
continue
|
||||
}
|
||||
if v != "tmpfs" {
|
||||
// Only tmpfs is supported now.
|
||||
continue
|
||||
}
|
||||
volume := volumeName(k)
|
||||
if uid != "" {
|
||||
// This is a sandbox
|
||||
@@ -143,8 +139,8 @@ func UpdateVolumeAnnotations(bundle string, s *specs.Spec) error {
|
||||
// more accurate matching.
|
||||
if yes, _ := isVolumePath(volume, s.Mounts[i].Source); yes {
|
||||
// gVisor requires the container mount type to match
|
||||
// sandbox mount type for tmpfs.
|
||||
s.Mounts[i].Type = "tmpfs"
|
||||
// sandbox mount type.
|
||||
s.Mounts[i].Type = v
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestUpdateVolumeAnnotations(t *testing.T) {
|
||||
expectUpdate: true,
|
||||
},
|
||||
{
|
||||
desc: "volume annotations for container",
|
||||
desc: "tmpfs: volume annotations for container",
|
||||
spec: &specs.Spec{
|
||||
Mounts: []specs.Mount{
|
||||
{
|
||||
@@ -150,6 +150,42 @@ func TestUpdateVolumeAnnotations(t *testing.T) {
|
||||
},
|
||||
expectUpdate: true,
|
||||
},
|
||||
{
|
||||
desc: "bind: volume annotations for container",
|
||||
spec: &specs.Spec{
|
||||
Mounts: []specs.Mount{
|
||||
{
|
||||
Destination: "/test",
|
||||
Type: "bind",
|
||||
Source: testVolumePath,
|
||||
Options: []string{"ro"},
|
||||
},
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
annotations.ContainerType: annotations.ContainerTypeContainer,
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/share": "container",
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/type": "bind",
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/options": "ro",
|
||||
},
|
||||
},
|
||||
expected: &specs.Spec{
|
||||
Mounts: []specs.Mount{
|
||||
{
|
||||
Destination: "/test",
|
||||
Type: "bind",
|
||||
Source: testVolumePath,
|
||||
Options: []string{"ro"},
|
||||
},
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
annotations.ContainerType: annotations.ContainerTypeContainer,
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/share": "container",
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/type": "bind",
|
||||
"gvisor.dev/spec/mount/" + testVolumeName + "/options": "ro",
|
||||
},
|
||||
},
|
||||
expectUpdate: true,
|
||||
},
|
||||
{
|
||||
desc: "should not return error without pod log directory",
|
||||
spec: &specs.Spec{
|
||||
|
||||
Reference in New Issue
Block a user