Skip to content

Commit d9fcd25

Browse files
committed
fix concurrent map write when streaming Docker logs
1 parent 2deb3fb commit d9fcd25

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

framework/.changeset/v0.11.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix concurrent map write when streaming Docker logs

framework/docker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ func StreamContainerLogs(listOptions container.ListOptions, logOptions container
368368

369369
eg := &errgroup.Group{}
370370
logMap := make(map[string]io.ReadCloser)
371+
var mutex sync.Mutex
371372

372373
for _, containerInfo := range containers {
373374
eg.Go(func() error {
@@ -378,6 +379,8 @@ func StreamContainerLogs(listOptions container.ListOptions, logOptions container
378379
L.Error().Err(err).Str("Container", containerName).Msg("failed to fetch logs for container")
379380
return err
380381
}
382+
mutex.Lock()
383+
defer mutex.Unlock()
381384
logMap[containerName] = logs
382385
return nil
383386
})

0 commit comments

Comments
 (0)