mirror of https://github.com/docker/compose.git
include volume_from as a source for implicit dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9c615dc22e
commit
4b808e569c
|
@ -101,7 +101,10 @@ func (s *composeService) create(ctx context.Context, project *types.Project, opt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareServicesDependsOn(project)
|
err = prepareServicesDependsOn(project)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return newConvergence(options.Services, observedState, s).apply(ctx, project, options)
|
return newConvergence(options.Services, observedState, s).apply(ctx, project, options)
|
||||||
}
|
}
|
||||||
|
@ -138,28 +141,55 @@ func prepareNetworks(project *types.Project) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareServicesDependsOn(p *types.Project) {
|
func prepareServicesDependsOn(p *types.Project) error {
|
||||||
outLoop:
|
for i, service := range p.Services {
|
||||||
for i := range p.Services {
|
var dependencies []string
|
||||||
networkDependency := getDependentServiceFromMode(p.Services[i].NetworkMode)
|
networkDependency := getDependentServiceFromMode(service.NetworkMode)
|
||||||
ipcDependency := getDependentServiceFromMode(p.Services[i].Ipc)
|
if networkDependency != "" {
|
||||||
pidDependency := getDependentServiceFromMode(p.Services[i].Pid)
|
dependencies = append(dependencies, networkDependency)
|
||||||
|
}
|
||||||
|
|
||||||
if networkDependency == "" && ipcDependency == "" && pidDependency == "" {
|
ipcDependency := getDependentServiceFromMode(service.Ipc)
|
||||||
|
if ipcDependency != "" {
|
||||||
|
dependencies = append(dependencies, ipcDependency)
|
||||||
|
}
|
||||||
|
|
||||||
|
pidDependency := getDependentServiceFromMode(service.Pid)
|
||||||
|
if pidDependency != "" {
|
||||||
|
dependencies = append(dependencies, pidDependency)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, vol := range service.VolumesFrom {
|
||||||
|
spec := strings.Split(vol, ":")
|
||||||
|
if len(spec) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if spec[0] == "container" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dependencies = append(dependencies, spec[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(dependencies) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if p.Services[i].DependsOn == nil {
|
if service.DependsOn == nil {
|
||||||
p.Services[i].DependsOn = make(types.DependsOnConfig)
|
service.DependsOn = make(types.DependsOnConfig)
|
||||||
}
|
}
|
||||||
for _, service := range p.Services {
|
deps, err := p.GetServices(dependencies...)
|
||||||
if service.Name == networkDependency || service.Name == ipcDependency || service.Name == pidDependency {
|
if err != nil {
|
||||||
p.Services[i].DependsOn[service.Name] = types.ServiceDependency{
|
return err
|
||||||
|
}
|
||||||
|
for _, d := range deps {
|
||||||
|
if _, ok := service.DependsOn[d.Name]; !ok {
|
||||||
|
service.DependsOn[d.Name] = types.ServiceDependency{
|
||||||
Condition: types.ServiceConditionStarted,
|
Condition: types.ServiceConditionStarted,
|
||||||
}
|
}
|
||||||
continue outLoop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
p.Services[i] = service
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) ensureNetworks(ctx context.Context, networks types.Networks) error {
|
func (s *composeService) ensureNetworks(ctx context.Context, networks types.Networks) error {
|
||||||
|
|
Loading…
Reference in New Issue