summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/fs.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-09-19 18:52:53 -0700
committerShentubot <shentubot@google.com>2018-09-19 18:54:14 -0700
commit915d76aa924c08b1fcb80a58e3caa24529a23d04 (patch)
tree7b43890499455af77c2d8fa279bf15838e69e643 /runsc/boot/fs.go
parentb873e388f36ee7251059d54a963c27a55be50ab5 (diff)
Add container.Destroy urpc method.
This method will: 1. Stop the container process if it is still running. 2. Unmount all sanadbox-internal mounts for the container. 3. Delete the contaner root directory inside the sandbox. Destroy is idempotent, and safe to call concurrantly. This fixes a bug where after stopping a container, we cannot unmount the container root directory on the host. This bug occured because the sandbox dirent cache was holding a dirent with a host fd corresponding to a file inside the container root on the host. The dirent cache did not know that the container had exited, and kept the FD open, preventing us from unmounting on the host. Now that we unmount (and flush) all container mounts inside the sandbox, any host FDs donated by the gofer will be closed, and we can unmount the container root on the host. PiperOrigin-RevId: 213737693 Change-Id: I28c0ff4cd19a08014cdd72fec5154497e92aacc9
Diffstat (limited to 'runsc/boot/fs.go')
-rw-r--r--runsc/boot/fs.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/runsc/boot/fs.go b/runsc/boot/fs.go
index 59ae5faae..110f67de8 100644
--- a/runsc/boot/fs.go
+++ b/runsc/boot/fs.go
@@ -49,9 +49,9 @@ const (
// Device name for root mount.
rootDevice = "9pfs-/"
- // childContainersDir is the directory where child container root
+ // ChildContainersDir is the directory where child container root
// filesystems are mounted.
- childContainersDir = "/__runsc_containers__"
+ ChildContainersDir = "/__runsc_containers__"
// Filesystems that runsc supports.
bind = "bind"
@@ -89,7 +89,7 @@ func createMountNamespace(userCtx context.Context, rootCtx context.Context, spec
// each child container.
mounts = append(mounts, specs.Mount{
Type: tmpfs,
- Destination: childContainersDir,
+ Destination: ChildContainersDir,
})
}
fds := &fdDispenser{fds: ioFDs}
@@ -639,7 +639,7 @@ func setFileSystemForProcess(procArgs *kernel.CreateProcessArgs, spec *specs.Spe
// Make directories for submounts within the container.
rootDir := mns.Root()
defer rootDir.DecRef()
- containerRoot := filepath.Join(childContainersDir, cid)
+ containerRoot := filepath.Join(ChildContainersDir, cid)
mkdirAll(ctx, mns, containerRoot)
// Mount the container's root filesystem to the newly created