mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-17 15:38:00 +00:00
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:
parent
8058fb0791
commit
47a6023382
@ -14,6 +14,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -43,7 +45,9 @@ func IsEphemeralStorage(path string) bool {
|
||||
if len(splitSourceSlice) > 1 {
|
||||
storageType := splitSourceSlice[len(splitSourceSlice)-2]
|
||||
if storageType == k8sEmptyDir {
|
||||
return true
|
||||
if _, fsType, _ := vc.GetDevicePathAndFsType(path); fsType == "tmpfs" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user