mirror of https://github.com/containers/podman.git
Don't start running dependencies
Before, a container being run or started in a pod always restarted the infra container. This was because we didn't take running dependencies into account. Fix this by filtering for dependencies in the running state. Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
parent
228d1cbcd3
commit
a784071902
|
@ -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())
|
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
|
// If there are no containers without dependencies, we can't start
|
||||||
// Error out
|
// Error out
|
||||||
if len(graph.noDepNodes) == 0 {
|
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())
|
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
|
// Traverse the graph beginning at nodes with no dependencies
|
||||||
for _, node := range graph.noDepNodes {
|
for _, node := range graph.noDepNodes {
|
||||||
startNode(ctx, node, false, ctrErrors, ctrsVisited, true)
|
startNode(ctx, node, false, ctrErrors, ctrsVisited, true)
|
||||||
|
@ -698,12 +701,20 @@ func (c *Container) getAllDependencies(visited map[string]*Container) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
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
|
visited[depID] = dep
|
||||||
if err := dep.getAllDependencies(visited); err != nil {
|
if err := dep.getAllDependencies(visited); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue