Skip to content

Commit

Permalink
retry failed creates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwelch committed Jul 10, 2015
1 parent c7b7a76 commit 5faf273
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions actions/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"io/ioutil"
"net/url"
"time"

log "github.com/Sirupsen/logrus"
"github.com/samalba/dockerclient"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5faf273

Please sign in to comment.