From 4be38f84dfa6571d706081941c5b60b936123a7c Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Sun, 20 Feb 2022 10:28:05 +0100 Subject: [PATCH] do not stop the dependencies wait process when reaching a dependency with service_started condition Signed-off-by: Guillaume Lours --- pkg/compose/convergence.go | 2 +- pkg/compose/convergence_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/compose/convergence.go b/pkg/compose/convergence.go index aa81fb37f..844cf3313 100644 --- a/pkg/compose/convergence.go +++ b/pkg/compose/convergence.go @@ -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 diff --git a/pkg/compose/convergence_test.go b/pkg/compose/convergence_test.go index 69bc39086..917af7af9 100644 --- a/pkg/compose/convergence_test.go +++ b/pkg/compose/convergence_test.go @@ -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)) + }) }