Merge pull request #943 from docker/fix_graph

Fix processing dependency graph only onces per node
This commit is contained in:
Guillaume Tardif 2020-11-20 18:04:23 +01:00 committed by GitHub
commit a4dfe706d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -31,9 +31,13 @@ func inDependencyOrder(ctx context.Context, project *types.Project, fn func(cont
eg, ctx := errgroup.WithContext(ctx)
results := make(chan string)
errors := make(chan error)
scheduled := map[string]bool{}
for len(graph) > 0 {
for _, n := range graph.independents() {
service := n.service
if scheduled[service.Name] {
continue
}
eg.Go(func() error {
err := fn(ctx, service)
if err != nil {
@ -43,6 +47,7 @@ func inDependencyOrder(ctx context.Context, project *types.Project, fn func(cont
results <- service.Name
return nil
})
scheduled[service.Name] = true
}
select {
case result := <-results: