Browse Source

exclude one-off container running convergence

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 10 months ago
parent
commit
b6db1380ec
2 changed files with 12 additions and 3 deletions
  1. 11 2
      pkg/compose/containers.go
  2. 1 1
      pkg/compose/convergence.go

+ 11 - 2
pkg/compose/containers.go

@@ -114,6 +114,15 @@ func (s *composeService) getSpecifiedContainer(ctx context.Context, projectName
 // containerPredicate define a predicate we want container to satisfy for filtering operations
 type containerPredicate func(c moby.Container) bool
 
+func matches(c moby.Container, predicates ...containerPredicate) bool {
+	for _, predicate := range predicates {
+		if !predicate(c) {
+			return false
+		}
+	}
+	return true
+}
+
 func isService(services ...string) containerPredicate {
 	return func(c moby.Container) bool {
 		service := c.Labels[api.ServiceLabel]
@@ -148,10 +157,10 @@ func isNotOneOff(c moby.Container) bool {
 }
 
 // filter return Containers with elements to match predicate
-func (containers Containers) filter(predicate containerPredicate) Containers {
+func (containers Containers) filter(predicates ...containerPredicate) Containers {
 	var filtered Containers
 	for _, c := range containers {
-		if predicate(c) {
+		if matches(c, predicates...) {
 			filtered = append(filtered, c)
 		}
 	}

+ 1 - 1
pkg/compose/convergence.go

@@ -460,7 +460,7 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr
 			continue
 		}
 
-		waitingFor := containers.filter(isService(dep))
+		waitingFor := containers.filter(isService(dep), isNotOneOff)
 		w.Events(containerEvents(waitingFor, progress.Waiting))
 		if len(waitingFor) == 0 {
 			if config.Required {