diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-12-28 13:47:19 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-28 13:48:24 -0800 |
commit | a891afad6d7e3b09bafdccb4cc4b9fc4e577620e (patch) | |
tree | 5dc0a3be78d6e06f24ddc22b9a4df7de094d09bf /runsc/boot/controller.go | |
parent | 652d068119052b0b3bc4a0808a4400a22380a30b (diff) |
Simplify synchronization between runsc and sandbox process
Make 'runsc create' join cgroup before creating sandbox process.
This removes the need to synchronize platform creation and ensure
that sandbox process is charged to the right cgroup from the start.
PiperOrigin-RevId: 227166451
Change-Id: Ieb4b18e6ca0daf7b331dc897699ca419bc5ee3a2
Diffstat (limited to 'runsc/boot/controller.go')
-rw-r--r-- | runsc/boot/controller.go | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go index 05d4f3a5b..36e9d2c6b 100644 --- a/runsc/boot/controller.go +++ b/runsc/boot/controller.go @@ -81,9 +81,6 @@ const ( // and return its ExitStatus. ContainerWait = "containerManager.Wait" - // ContainerWaitForLoader blocks until the container's loader has been created. - ContainerWaitForLoader = "containerManager.WaitForLoader" - // ContainerWaitPID is used to wait on a process with a certain PID in // the sandbox and return its ExitStatus. ContainerWaitPID = "containerManager.WaitPID" @@ -115,21 +112,22 @@ type controller struct { manager *containerManager } -// newController creates a new controller and starts it listening. -func newController(fd int, k *kernel.Kernel, w *watchdog.Watchdog) (*controller, error) { +// newController creates a new controller. The caller must call +// controller.srv.StartServing() to start the controller. +func newController(fd int, l *Loader) (*controller, error) { srv, err := server.CreateFromFD(fd) if err != nil { return nil, err } manager := &containerManager{ - startChan: make(chan struct{}), - startResultChan: make(chan error), - loaderCreatedChan: make(chan struct{}), + startChan: make(chan struct{}), + startResultChan: make(chan error), + l: l, } srv.Register(manager) - if eps, ok := k.NetworkStack().(*epsocket.Stack); ok { + if eps, ok := l.k.NetworkStack().(*epsocket.Stack); ok { net := &Network{ Stack: eps.Stack, } @@ -138,10 +136,6 @@ func newController(fd int, k *kernel.Kernel, w *watchdog.Watchdog) (*controller, srv.Register(&debug{}) - if err := srv.StartServing(); err != nil { - return nil, err - } - return &controller{ srv: srv, manager: manager, @@ -161,11 +155,6 @@ type containerManager struct { // l is the loader that creates containers and sandboxes. l *Loader - - // loaderCreatedChan is used to signal when the loader has been created. - // After a loader is created, a notify method is called that writes to - // this channel. - loaderCreatedChan chan struct{} } // StartRoot will start the root container process. @@ -291,13 +280,6 @@ func (cm *containerManager) Pause(_, _ *struct{}) error { return nil } -// WaitForLoader blocks until the container's loader has been created. -func (cm *containerManager) WaitForLoader(_, _ *struct{}) error { - log.Debugf("containerManager.WaitForLoader") - <-cm.loaderCreatedChan - return nil -} - // RestoreOpts contains options related to restoring a container's file system. type RestoreOpts struct { // FilePayload contains the state file to be restored, followed by the |