Skip to content

Commit

Permalink
Fix getContainerStats error
Browse files Browse the repository at this point in the history
* new variable for closure
* wg.Add before go func()
  • Loading branch information
pioh authored May 16, 2022
1 parent c67d87a commit 5cbf559
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ func (ds *dockerService) ListContainerStats(
var wg sync.WaitGroup
var stats = make([]*runtimeapi.ContainerStats, 0, len(listResp.Containers))
for _, container := range listResp.Containers {
container := container
wg.Add(1)
go func() {
wg.Add(1)
defer wg.Done()
if containerStats, err := ds.getContainerStats(container.Id); err == nil && containerStats != nil {
mtx.Lock()
Expand Down

0 comments on commit 5cbf559

Please sign in to comment.