소스 검색

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

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours 3 년 전
부모
커밋
4be38f84df
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      pkg/compose/convergence.go
  2. 10 0
      pkg/compose/convergence_test.go

+ 1 - 1
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

+ 10 - 0
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))
+	})
 }