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)
|
||||
}
|
||||
|
@ -138,28 +141,55 @@ func prepareNetworks(project *types.Project) {
|
|||
}
|
||||
}
|
||||
|
||||
func prepareServicesDependsOn(p *types.Project) {
|
||||
outLoop:
|
||||
for i := range p.Services {
|
||||
networkDependency := getDependentServiceFromMode(p.Services[i].NetworkMode)
|
||||
ipcDependency := getDependentServiceFromMode(p.Services[i].Ipc)
|
||||
pidDependency := getDependentServiceFromMode(p.Services[i].Pid)
|
||||
func prepareServicesDependsOn(p *types.Project) error {
|
||||
for i, service := range p.Services {
|
||||
var dependencies []string
|
||||
networkDependency := getDependentServiceFromMode(service.NetworkMode)
|
||||
if networkDependency != "" {
|
||||
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 p.Services[i].DependsOn == nil {
|
||||
p.Services[i].DependsOn = make(types.DependsOnConfig)
|
||||
if spec[0] == "container" {
|
||||
continue
|
||||
}
|
||||
for _, service := range p.Services {
|
||||
if service.Name == networkDependency || service.Name == ipcDependency || service.Name == pidDependency {
|
||||
p.Services[i].DependsOn[service.Name] = types.ServiceDependency{
|
||||
dependencies = append(dependencies, spec[0])
|
||||
}
|
||||
|
||||
if len(dependencies) == 0 {
|
||||
continue
|
||||
}
|
||||
if service.DependsOn == nil {
|
||||
service.DependsOn = make(types.DependsOnConfig)
|
||||
}
|
||||
deps, err := p.GetServices(dependencies...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, d := range deps {
|
||||
if _, ok := service.DependsOn[d.Name]; !ok {
|
||||
service.DependsOn[d.Name] = types.ServiceDependency{
|
||||
Condition: types.ServiceConditionStarted,
|
||||
}
|
||||
continue outLoop
|
||||
}
|
||||
}
|
||||
p.Services[i] = service
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *composeService) ensureNetworks(ctx context.Context, networks types.Networks) error {
|
||||
|
|
Loading…
Reference in New Issue