Skip to content

Commit b6db138

Browse files
ndeloofglours
authored andcommitted
exclude one-off container running convergence
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 2ebb475 commit b6db138

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/compose/containers.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ func (s *composeService) getSpecifiedContainer(ctx context.Context, projectName
114114
// containerPredicate define a predicate we want container to satisfy for filtering operations
115115
type containerPredicate func(c moby.Container) bool
116116

117+
func matches(c moby.Container, predicates ...containerPredicate) bool {
118+
for _, predicate := range predicates {
119+
if !predicate(c) {
120+
return false
121+
}
122+
}
123+
return true
124+
}
125+
117126
func isService(services ...string) containerPredicate {
118127
return func(c moby.Container) bool {
119128
service := c.Labels[api.ServiceLabel]
@@ -148,10 +157,10 @@ func isNotOneOff(c moby.Container) bool {
148157
}
149158

150159
// filter return Containers with elements to match predicate
151-
func (containers Containers) filter(predicate containerPredicate) Containers {
160+
func (containers Containers) filter(predicates ...containerPredicate) Containers {
152161
var filtered Containers
153162
for _, c := range containers {
154-
if predicate(c) {
163+
if matches(c, predicates...) {
155164
filtered = append(filtered, c)
156165
}
157166
}

pkg/compose/convergence.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr
460460
continue
461461
}
462462

463-
waitingFor := containers.filter(isService(dep))
463+
waitingFor := containers.filter(isService(dep), isNotOneOff)
464464
w.Events(containerEvents(waitingFor, progress.Waiting))
465465
if len(waitingFor) == 0 {
466466
if config.Required {

0 commit comments

Comments
 (0)