summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/loader.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-12-28 13:47:19 -0800
committerShentubot <shentubot@google.com>2018-12-28 13:48:24 -0800
commita891afad6d7e3b09bafdccb4cc4b9fc4e577620e (patch)
tree5dc0a3be78d6e06f24ddc22b9a4df7de094d09bf /runsc/boot/loader.go
parent652d068119052b0b3bc4a0808a4400a22380a30b (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/loader.go')
-rw-r--r--runsc/boot/loader.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index a9c549790..3c6892446 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -277,20 +277,6 @@ func New(args Args) (*Loader, error) {
// Create a watchdog.
watchdog := watchdog.New(k, watchdog.DefaultTimeout, args.Conf.WatchdogAction)
- // Create the control server using the provided FD.
- //
- // This must be done *after* we have initialized the kernel since the
- // controller is used to configure the kernel's network stack.
- //
- // This should also be *before* we create the process, since a
- // misconfigured process will cause an error, and we want the control
- // server up before that so that we don't time out trying to connect to
- // it.
- ctrl, err := newController(args.ControllerFD, k, watchdog)
- if err != nil {
- return nil, fmt.Errorf("error creating control server: %v", err)
- }
-
procArgs, err := newProcess(args.ID, args.Spec, creds, k)
if err != nil {
return nil, fmt.Errorf("failed to create init process for root container: %v", err)
@@ -303,7 +289,6 @@ func New(args Args) (*Loader, error) {
eid := execID{cid: args.ID}
l := &Loader{
k: k,
- ctrl: ctrl,
conf: args.Conf,
console: args.Console,
watchdog: watchdog,
@@ -348,7 +333,22 @@ func New(args Args) (*Loader, error) {
}
})
- ctrl.manager.l = l
+ // Create the control server using the provided FD.
+ //
+ // This must be done *after* we have initialized the kernel since the
+ // controller is used to configure the kernel's network stack.
+ ctrl, err := newController(args.ControllerFD, l)
+ if err != nil {
+ return nil, fmt.Errorf("creating control server: %v", err)
+ }
+ l.ctrl = ctrl
+
+ // Only start serving after Loader is set to controller and controller is set
+ // to Loader, because they are both used in the urpc methods.
+ if err := ctrl.srv.StartServing(); err != nil {
+ return nil, fmt.Errorf("starting control server: %v", err)
+ }
+
return l, nil
}
@@ -745,12 +745,6 @@ func (l *Loader) WaitForStartSignal() {
<-l.ctrl.manager.startChan
}
-// NotifyLoaderCreated sends a signal to the container manager that this
-// loader has been created.
-func (l *Loader) NotifyLoaderCreated() {
- l.ctrl.manager.loaderCreatedChan <- struct{}{}
-}
-
// WaitExit waits for the root container to exit, and returns its exit status.
func (l *Loader) WaitExit() kernel.ExitStatus {
// Wait for container.