Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
volumes: Handle k8s empty-dirs of "default" medium type
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
amshinde committed Mar 15, 2019
1 parent 8058fb0 commit 47a6023
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pkg/katautils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"path/filepath"
"strings"
"syscall"

vc "github.com/kata-containers/runtime/virtcontainers"
)

const (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion virtcontainers/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions virtcontainers/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ func TestGetDeviceForPathBindMount(t *testing.T) {
}

func TestGetDevicePathAndFsTypeEmptyMount(t *testing.T) {
_, _, err := getDevicePathAndFsType("")
_, _, err := GetDevicePathAndFsType("")

if err == nil {
t.Fatal()
}
}

func TestGetDevicePathAndFsTypeSuccessful(t *testing.T) {
path, fstype, err := getDevicePathAndFsType("/proc")
path, fstype, err := GetDevicePathAndFsType("/proc")

if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 47a6023

Please sign in to comment.