Skip to content

Commit 172d095

Browse files
committed
Fix race in host sandbox creation
Since we share the host sandbox with many containers we need to serialize creation of the sandbox. Otherwise container starts may see the namespace path in inconsistent state. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
1 parent cd5c267 commit 172d095

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,14 @@ func (c *controller) NewSandbox(containerID string, options ...SandboxOption) (S
507507
return nil, err
508508
}
509509

510+
c.Lock()
510511
if sb.osSbox == nil && !sb.config.useExternalKey {
511512
if sb.osSbox, err = osl.NewSandbox(sb.Key(), !sb.config.useDefaultSandBox); err != nil {
513+
c.Unlock()
512514
return nil, fmt.Errorf("failed to create new osl sandbox: %v", err)
513515
}
514516
}
515517

516-
c.Lock()
517518
c.sandboxes[sb.id] = sb
518519
c.Unlock()
519520
defer func() {

0 commit comments

Comments
 (0)