volumes: Handle k8s empty-dirs of "default" medium type

We were considering all empty-dir k8s volumes as backed by tmpfs.
However they can be backed by a host directory as well.
Pass those as 9p volumes, while tmpfs volumes are handled as before,
namely creating a tmpfs directory inside the guest.
The only way to detect "Memory" empty-dirs is to actually check if the
volume is mounted as a tmpfs mount, since any information of k8s
"medium" is lost at the OCI layer.

Fixes #1341

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2019-03-14 18:05:09 -07:00
parent 8058fb0791
commit 47a6023382
4 changed files with 11 additions and 5 deletions

View File

@ -14,6 +14,8 @@ import (
"path/filepath"
"strings"
"syscall"
vc "github.com/kata-containers/runtime/virtcontainers"
)
const (
@ -43,9 +45,11 @@ func IsEphemeralStorage(path string) bool {
if len(splitSourceSlice) > 1 {
storageType := splitSourceSlice[len(splitSourceSlice)-2]
if storageType == k8sEmptyDir {
if _, fsType, _ := vc.GetDevicePathAndFsType(path); fsType == "tmpfs" {
return true
}
}
}
return false
}

View File

@ -1138,7 +1138,7 @@ func (c *Container) hotplugDrive() error {
}
// If device mapper device, then fetch the full path of the device
devicePath, fsType, err := getDevicePathAndFsType(dev.mountPoint)
devicePath, fsType, err := GetDevicePathAndFsType(dev.mountPoint)
if err != nil {
return err
}

View File

@ -164,7 +164,9 @@ const (
procTypeIndex
)
func getDevicePathAndFsType(mountPoint string) (devicePath, fsType string, err error) {
// GetDevicePathAndFsType gets the device for the mount point and the file system type
// of the mount.
func GetDevicePathAndFsType(mountPoint string) (devicePath, fsType string, err error) {
if mountPoint == "" {
err = fmt.Errorf("Mount point cannot be empty")
return

View File

@ -238,7 +238,7 @@ func TestGetDeviceForPathBindMount(t *testing.T) {
}
func TestGetDevicePathAndFsTypeEmptyMount(t *testing.T) {
_, _, err := getDevicePathAndFsType("")
_, _, err := GetDevicePathAndFsType("")
if err == nil {
t.Fatal()
@ -246,7 +246,7 @@ func TestGetDevicePathAndFsTypeEmptyMount(t *testing.T) {
}
func TestGetDevicePathAndFsTypeSuccessful(t *testing.T) {
path, fstype, err := getDevicePathAndFsType("/proc")
path, fstype, err := GetDevicePathAndFsType("/proc")
if err != nil {
t.Fatal(err)