diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-11-25 17:10:10 -0800 |
---|---|---|
committer | Lantao Liu <lantaol@google.com> | 2019-11-25 17:10:10 -0800 |
commit | 67745b88e0ddcc44dcc7629be0334a7d970d6e09 (patch) | |
tree | ba2d07207b3dafca32b42285f5c619a9fe2f6e3b /pkg | |
parent | f299b553afdd8455a0057862004061ea12e660f5 (diff) |
Handle any volume type, not only tmpfs (#42)
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/v1/utils/volumes.go | 8 | ||||
-rw-r--r-- | pkg/v1/utils/volumes_test.go | 38 |
2 files changed, 39 insertions, 7 deletions
diff --git a/pkg/v1/utils/volumes.go b/pkg/v1/utils/volumes.go index cd27f6de5..02a70a8b6 100644 --- a/pkg/v1/utils/volumes.go +++ b/pkg/v1/utils/volumes.go @@ -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 } } diff --git a/pkg/v1/utils/volumes_test.go b/pkg/v1/utils/volumes_test.go index 8e7d4a940..8a6a30ef1 100644 --- a/pkg/v1/utils/volumes_test.go +++ b/pkg/v1/utils/volumes_test.go @@ -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{ { @@ -151,6 +151,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{ Annotations: map[string]string{ |