summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-19 16:43:27 +0100
committerGitHub <noreply@github.com>2019-02-19 16:43:27 +0100
commite92f7ca7dd64ebcc29ce105f997d9a748792f6cd (patch)
treee5bc618ad05d2970df2cadd8bdbc2778afef859e
parent228d1cbcd372b086669e35c1237fc5064b24ea7d (diff)
parenta784071902e2c78c3fd9db106df7ad1f49edb8a6 (diff)
downloadpodman-e92f7ca7dd64ebcc29ce105f997d9a748792f6cd.tar.gz
podman-e92f7ca7dd64ebcc29ce105f997d9a748792f6cd.tar.bz2
podman-e92f7ca7dd64ebcc29ce105f997d9a748792f6cd.zip
Merge pull request #2366 from haircommander/dont-start-started-deps
Don't start running dependencies
-rw-r--r--libpod/container_internal.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index b5f93c8a0..e3753d825 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -652,16 +652,19 @@ func (c *Container) startDependencies(ctx context.Context) error {
return errors.Wrapf(err, "error generating dependency graph for container %s", c.ID())
}
- ctrErrors := make(map[string]error)
- // reset ctrsVisisted for next round of recursion
- ctrsVisited := make(map[string]bool)
-
// If there are no containers without dependencies, we can't start
// Error out
if len(graph.noDepNodes) == 0 {
+ // we have no dependencies that need starting, go ahead and return
+ if len(graph.nodes) == 0 {
+ return nil
+ }
return errors.Wrapf(ErrNoSuchCtr, "All dependencies have dependencies of %s", c.ID())
}
+ ctrErrors := make(map[string]error)
+ ctrsVisited := make(map[string]bool)
+
// Traverse the graph beginning at nodes with no dependencies
for _, node := range graph.noDepNodes {
startNode(ctx, node, false, ctrErrors, ctrsVisited, true)
@@ -698,10 +701,18 @@ func (c *Container) getAllDependencies(visited map[string]*Container) error {
if err != nil {
return err
}
- visited[depID] = dep
- if err := dep.getAllDependencies(visited); err != nil {
+ status, err := dep.State()
+ if err != nil {
return err
}
+ // if the dependency is already running, we can assume its dependencies are also running
+ // so no need to add them to those we need to start
+ if status != ContainerStateRunning {
+ visited[depID] = dep
+ if err := dep.getAllDependencies(visited); err != nil {
+ return err
+ }
+ }
}
}
return nil