From 5faf273cc99d9d8533ea2bd795916807bd09c844 Mon Sep 17 00:00:00 2001 From: Alex Welch Date: Fri, 10 Jul 2015 21:25:57 +0000 Subject: [PATCH] retry failed creates --- actions/endpoint.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/actions/endpoint.go b/actions/endpoint.go index e589847..65edd07 100644 --- a/actions/endpoint.go +++ b/actions/endpoint.go @@ -6,6 +6,7 @@ import ( "encoding/json" "io/ioutil" "net/url" + "time" log "github.com/Sirupsen/logrus" "github.com/samalba/dockerclient" @@ -105,9 +106,17 @@ func (e *DockerEndpoint) Name() string { func (e *DockerEndpoint) StartContainer(name string, cc ContainerConfig) error { dcc, _ := translateContainerConfig(cc) - id, err := e.client.CreateContainer(&dcc, name) - if err != nil { - log.Fatalf("Problem creating container: ", err) + var id string + for { + cid, err := e.client.CreateContainer(&dcc, name) + if err == nil { + id = cid + break + } else { + log.Infof("Problem creating container: ", err) + log.Infof("Retrying create...") + time.Sleep(5 * time.Second) + } } log.Infof("%s created as %s", name, id)