From 7f1030d30305144acbce788fe25d06fc4b55ddb3 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Thu, 20 May 2021 16:01:47 -0700 Subject: [PATCH] sandbox-bindmount: persist mount information Without this, if the shim dies, we will not have a reliable way to identify what mounts should be cleaned up if `containerd-shim-kata-v2 cleanup` is called for the sandbox. Before this, if you `ctr run` with a sandbox bindmount defined and SIGKILL the containerd-shim-kata-v2, you'll notice the sandbox bindmount left on host. With this change, the shim is able to get the sandbox bindmount information from disk and do the appropriate cleanup. Fixes #1896 Signed-off-by: Eric Ernst --- src/runtime/virtcontainers/persist.go | 3 +++ src/runtime/virtcontainers/persist/api/config.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/runtime/virtcontainers/persist.go b/src/runtime/virtcontainers/persist.go index 044a3cde56..203495e823 100644 --- a/src/runtime/virtcontainers/persist.go +++ b/src/runtime/virtcontainers/persist.go @@ -191,6 +191,8 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) { Cgroups: sconfig.Cgroups, } + ss.Config.SandboxBindMounts = append(ss.Config.SandboxBindMounts, sconfig.SandboxBindMounts...) + for _, e := range sconfig.Experimental { ss.Config.Experimental = append(ss.Config.Experimental, e.Name) } @@ -459,6 +461,7 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) { DisableGuestSeccomp: savedConf.DisableGuestSeccomp, Cgroups: savedConf.Cgroups, } + sconfig.SandboxBindMounts = append(sconfig.SandboxBindMounts, savedConf.SandboxBindMounts...) for _, name := range savedConf.Experimental { sconfig.Experimental = append(sconfig.Experimental, *exp.Get(name)) diff --git a/src/runtime/virtcontainers/persist/api/config.go b/src/runtime/virtcontainers/persist/api/config.go index 93cd514333..3bd5567dbe 100644 --- a/src/runtime/virtcontainers/persist/api/config.go +++ b/src/runtime/virtcontainers/persist/api/config.go @@ -275,6 +275,9 @@ type SandboxConfig struct { DisableGuestSeccomp bool + // SandboxBindMounts - list of paths to mount into guest + SandboxBindMounts []string + // Experimental enables experimental features Experimental []string