summaryrefslogtreecommitdiffhomepage
path: root/runsc/sandbox/sandbox.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-05-03 21:08:38 -0700
committerShentubot <shentubot@google.com>2018-05-03 21:09:31 -0700
commitc186ebb62a6005288d83feed0e43cca9f0577383 (patch)
treec36a976d6aaec2d09435f96fb0cbd4e0168d9bba /runsc/sandbox/sandbox.go
parent58235b1840db01aa2ede311efa782eac60767722 (diff)
Return error when child exits early
PiperOrigin-RevId: 195365050 Change-Id: I8754dc7a3fc2975d422cae453762a455478a8e6a
Diffstat (limited to 'runsc/sandbox/sandbox.go')
-rw-r--r--runsc/sandbox/sandbox.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go
index 954824ada..13bf5d800 100644
--- a/runsc/sandbox/sandbox.go
+++ b/runsc/sandbox/sandbox.go
@@ -560,19 +560,20 @@ func (s *Sandbox) createSandboxProcess(conf *boot.Config, binPath string, common
// running, at which point the sandbox is in Created state.
func (s *Sandbox) waitForCreated(timeout time.Duration) error {
log.Debugf("Waiting for sandbox %q creation", s.ID)
- tchan := time.After(timeout)
- for {
- select {
- case <-tchan:
- return fmt.Errorf("timed out waiting for sandbox control server")
- default:
- if c, err := client.ConnectTo(boot.ControlSocketAddr(s.ID)); err == nil {
- // It's alive!
- c.Close()
- return nil
- }
+
+ ready := func() (bool, error) {
+ c, err := client.ConnectTo(boot.ControlSocketAddr(s.ID))
+ if err != nil {
+ return false, nil
}
+ // It's alive!
+ c.Close()
+ return true, nil
}
+ if err := specutils.WaitForReady(s.Pid, timeout, ready); err != nil {
+ return fmt.Errorf("unexpected error waiting for sandbox %q, err: %v", s.ID, err)
+ }
+ return nil
}
// Wait waits for the containerized process to exit, and returns its WaitStatus.