Merge pull request #1647 from gtardif/fix_race_depens_on

Avoid using for variable in go func, as this creates race conditions
This commit is contained in:
Nicolas De loof 2021-05-06 10:02:20 +02:00 committed by GitHub
commit c308e1f1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -147,6 +147,7 @@ func getContainerProgressName(container moby.Container) string {
func (s *composeService) waitDependencies(ctx context.Context, project *types.Project, service types.ServiceConfig) error { func (s *composeService) waitDependencies(ctx context.Context, project *types.Project, service types.ServiceConfig) error {
eg, _ := errgroup.WithContext(ctx) eg, _ := errgroup.WithContext(ctx)
for dep, config := range service.DependsOn { for dep, config := range service.DependsOn {
dep, config := dep, config
eg.Go(func() error { eg.Go(func() error {
ticker := time.NewTicker(500 * time.Millisecond) ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()