summaryrefslogtreecommitdiffhomepage
path: root/runsc/cmd/exec.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-05-15 10:17:19 -0700
committerShentubot <shentubot@google.com>2018-05-15 10:18:03 -0700
commit205f1027e6beb84101439172b3c776c2671b5be8 (patch)
tree10294e667ee529e140c474c475e7309cb72ea1d8 /runsc/cmd/exec.go
parented02ac4f668ec41063cd51cbbd451baba9e9a6e7 (diff)
Refactor the Sandbox package into Sandbox + Container.
This is a necessary prerequisite for supporting multiple containers in a single sandbox. All the commands (in cmd package) now call operations on Containers (container package). When a Container first starts, it will create a Sandbox with the same ID. The Sandbox class is now simpler, as it only knows how to create boot/gofer processes, and how to forward commands into the running boot process. There are TODOs sprinkled around for additional support for multiple containers. Most notably, we need to detect when a container is intended to run in an existing sandbox (by reading the metadata), and then have some way to signal to the sandbox to start a new container. Other urpc calls into the sandbox need to pass the container ID, so the sandbox can run the operation on the given container. These are only half-plummed through right now. PiperOrigin-RevId: 196688269 Change-Id: I1ecf4abbb9dd8987a53ae509df19341aaf42b5b0
Diffstat (limited to 'runsc/cmd/exec.go')
-rw-r--r--runsc/cmd/exec.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/runsc/cmd/exec.go b/runsc/cmd/exec.go
index 052e00316..235ed9bc6 100644
--- a/runsc/cmd/exec.go
+++ b/runsc/cmd/exec.go
@@ -34,7 +34,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/kernel/auth"
"gvisor.googlesource.com/gvisor/pkg/urpc"
"gvisor.googlesource.com/gvisor/runsc/boot"
- "gvisor.googlesource.com/gvisor/runsc/sandbox"
+ "gvisor.googlesource.com/gvisor/runsc/container"
"gvisor.googlesource.com/gvisor/runsc/specutils"
)
@@ -89,11 +89,11 @@ func (ex *Exec) SetFlags(f *flag.FlagSet) {
f.Var(&ex.caps, "cap", "add a capability to the bounding set for the process")
f.BoolVar(&ex.detach, "detach", false, "detach from the container's process")
f.StringVar(&ex.processPath, "process", "", "path to the process.json")
- f.StringVar(&ex.pidFile, "pid-file", "", "filename that the sandbox pid will be written to")
+ f.StringVar(&ex.pidFile, "pid-file", "", "filename that the container pid will be written to")
}
// Execute implements subcommands.Command.Execute. It starts a process in an
-// already created sandbox.
+// already created container.
func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
e, id, err := ex.parseArgs(f)
if err != nil {
@@ -102,17 +102,17 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
conf := args[0].(*boot.Config)
waitStatus := args[1].(*syscall.WaitStatus)
- s, err := sandbox.Load(conf.RootDir, id)
+ c, err := container.Load(conf.RootDir, id)
if err != nil {
Fatalf("error loading sandox: %v", err)
}
if e.WorkingDirectory == "" {
- e.WorkingDirectory = s.Spec.Process.Cwd
+ e.WorkingDirectory = c.Spec.Process.Cwd
}
if e.Envv == nil {
- e.Envv, err = resolveEnvs(s.Spec.Process.Env, ex.env)
+ e.Envv, err = resolveEnvs(c.Spec.Process.Env, ex.env)
if err != nil {
Fatalf("error getting environment variables: %v", err)
}
@@ -136,15 +136,15 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
// inspect the environment PATH which is relative to the root path.
// If the user is overriding environment variables, PATH may have been
// overwritten.
- rootPath := s.Spec.Root.Path
+ rootPath := c.Spec.Root.Path
e.Filename, err = specutils.GetExecutablePath(e.Argv[0], rootPath, e.Envv)
if err != nil {
Fatalf("error getting executable path: %v", err)
}
- ws, err := s.Execute(e)
+ ws, err := c.Execute(e)
if err != nil {
- Fatalf("error getting processes for sandbox: %v", err)
+ Fatalf("error getting processes for container: %v", err)
}
*waitStatus = ws
return subcommands.ExitSuccess
@@ -196,7 +196,7 @@ func (ex *Exec) execAndWait(waitStatus *syscall.WaitStatus) subcommands.ExitStat
// parseArgs parses exec information from the command line or a JSON file
// depending on whether the --process flag was used. Returns an ExecArgs and
-// the ID of the sandbox to be used.
+// the ID of the container to be used.
func (ex *Exec) parseArgs(f *flag.FlagSet) (*control.ExecArgs, string, error) {
if ex.processPath == "" {
// Requires at least a container ID and command.