diff options
author | Kevin Krakauer <krakauer@google.com> | 2018-06-22 14:30:33 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-06-22 14:31:25 -0700 |
commit | 04bdcc7b65ac03eeca9b14608a12067e1205081b (patch) | |
tree | e88ce30df1c5b433f44a51e8cbb211f56f6306dc /runsc/boot/controller.go | |
parent | e0e640981282ece051c33700f4e272047fa4e5b6 (diff) |
runsc: Enable waiting on individual containers within a sandbox.
PiperOrigin-RevId: 201742160
Change-Id: Ia9fa1442287c5f9e1196fb117c41536a80f6bb31
Diffstat (limited to 'runsc/boot/controller.go')
-rw-r--r-- | runsc/boot/controller.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go index ec24c4dad..56829c605 100644 --- a/runsc/boot/controller.go +++ b/runsc/boot/controller.go @@ -145,10 +145,11 @@ type containerManager struct { } // StartRoot will start the root container process. -func (cm *containerManager) StartRoot(_, _ *struct{}) error { +func (cm *containerManager) StartRoot(cid *string, _ *struct{}) error { log.Debugf("containerManager.StartRoot") // Tell the root container to start and wait for the result. cm.startChan <- struct{}{} + cm.l.setRootContainerID(*cid) return <-cm.startResultChan } @@ -166,6 +167,9 @@ type StartArgs struct { // TODO: Separate sandbox and container configs. // Config is the runsc-specific configuration for the sandbox. Conf *Config + + // CID is the ID of the container to start. + CID string } // Start runs a created container within a sandbox. @@ -182,8 +186,16 @@ func (cm *containerManager) Start(args *StartArgs, _ *struct{}) error { if args.Conf == nil { return errors.New("start arguments missing config") } + if args.CID == "" { + return errors.New("start argument missing container ID") + } + + tgid, err := cm.l.startContainer(args, cm.k) + if err != nil { + return err + } + log.Debugf("Container %q started with root PID of %d", args.CID, tgid) - cm.l.startContainer(args, cm.k) return nil } @@ -222,15 +234,7 @@ func (cm *containerManager) Resume(_, _ *struct{}) error { // Wait waits for the init process in the given container. func (cm *containerManager) Wait(cid *string, waitStatus *uint32) error { log.Debugf("containerManager.Wait") - // TODO: Use the cid and wait on the init process in that - // container. Currently we just wait on PID 1 in the sandbox. - tg := cm.k.TaskSet().Root.ThreadGroupWithID(1) - if tg == nil { - return fmt.Errorf("cannot wait: no thread group with id 1") - } - tg.WaitExited() - *waitStatus = tg.ExitStatus().Status() - return nil + return cm.l.wait(cid, waitStatus) } // SignalArgs are arguments to the Signal method. |