mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #25550 from mrjana/net
Retry creating dynamic networks if not found
This commit is contained in:
commit
92b10b497c
1 changed files with 18 additions and 2 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
"github.com/docker/engine-api/types"
|
||||
"github.com/docker/engine-api/types/events"
|
||||
"github.com/docker/libnetwork"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/log"
|
||||
|
@ -163,8 +164,23 @@ func (r *controller) Start(ctx context.Context) error {
|
|||
return exec.ErrTaskStarted
|
||||
}
|
||||
|
||||
if err := r.adapter.start(ctx); err != nil {
|
||||
return errors.Wrap(err, "starting container failed")
|
||||
for {
|
||||
if err := r.adapter.start(ctx); err != nil {
|
||||
if _, ok := err.(libnetwork.ErrNoSuchNetwork); ok {
|
||||
// Retry network creation again if we
|
||||
// failed because some of the networks
|
||||
// were not found.
|
||||
if err := r.adapter.createNetworks(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "starting container failed")
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
// no health check
|
||||
|
|
Loading…
Add table
Reference in a new issue