Skip to content

Commit

Permalink
Add nil check for result of getContainerStats (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
neersighted authored Mar 8, 2024
2 parents 7b5b6d4 + ab0c613 commit 1450172
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (ds *dockerService) ContainerStats(
if err != nil {
return nil, err
}
if stats == nil {
return nil, fmt.Errorf("stats for container with id %s not available", r.ContainerId)
}
return &runtimeapi.ContainerStatsResponse{Stats: stats}, nil
}

Expand Down Expand Up @@ -232,7 +235,9 @@ func (ds *dockerService) ListContainerStats(
return nil
}
mu.Lock()
results = append(results, stats)
if stats != nil {
results = append(results, stats)
}
mu.Unlock()
return nil
})
Expand Down

0 comments on commit 1450172

Please sign in to comment.