fix: concurrent map writes when pulling
Signed-off-by: skanehira <sho19921005@gmail.com>
This commit is contained in:
parent
a96c305b25
commit
bf6b447263
@ -24,6 +24,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
@ -322,9 +323,12 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
|
|||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
eg.SetLimit(s.maxConcurrency)
|
eg.SetLimit(s.maxConcurrency)
|
||||||
pulledImages := map[string]api.ImageSummary{}
|
pulledImages := map[string]api.ImageSummary{}
|
||||||
|
var mutex sync.Mutex
|
||||||
for name, service := range needPull {
|
for name, service := range needPull {
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
pulledImages[name] = api.ImageSummary{
|
pulledImages[name] = api.ImageSummary{
|
||||||
ID: id,
|
ID: id,
|
||||||
Repository: service.Image,
|
Repository: service.Image,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user