do not stop the dependencies wait process when reaching a dependency with service_started condition

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
Guillaume Lours 2022-02-20 10:28:05 +01:00
parent 09e0fa94b8
commit 4be38f84df
2 changed files with 11 additions and 1 deletions

View File

@ -278,7 +278,7 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr
for dep, config := range dependencies {
if config.Condition == types.ServiceConditionStarted {
// already managed by InDependencyOrder
return nil
continue
}
if service, err := project.GetService(dep); err != nil {
return err

View File

@ -202,4 +202,14 @@ func TestWaitDependencies(t *testing.T) {
}
assert.NilError(t, tested.waitDependencies(context.Background(), &project, dependencies))
})
t.Run("should skip dependencies with condition service_started", func(t *testing.T) {
dbService := types.ServiceConfig{Name: "db", Scale: 1}
redisService := types.ServiceConfig{Name: "redis", Scale: 1}
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{dbService, redisService}}
dependencies := types.DependsOnConfig{
"db": {Condition: types.ServiceConditionStarted},
"redis": {Condition: types.ServiceConditionStarted},
}
assert.NilError(t, tested.waitDependencies(context.Background(), &project, dependencies))
})
}