summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-27 09:26:39 -0400
committerGitHub <noreply@github.com>2020-05-27 09:26:39 -0400
commit9cb5c87284377507aafae8456ee8f00823954712 (patch)
treee29f0111c611f87870213129f29cd4ab3c30f73a /cmd
parent119e13d4bcc3e8da903da33b291f2795b0e76e71 (diff)
parent3cef598fc2b2d75ceb02ea8546327b03bc927b55 (diff)
downloadpodman-9cb5c87284377507aafae8456ee8f00823954712.tar.gz
podman-9cb5c87284377507aafae8456ee8f00823954712.tar.bz2
podman-9cb5c87284377507aafae8456ee8f00823954712.zip
Merge pull request #6406 from vrothberg/stats-race
container stats: fix --no-stream race
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/stats.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index 5b7f52cc7..c61b161e4 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
+ "sync"
"text/tabwriter"
"text/template"
@@ -111,14 +112,20 @@ func stats(cmd *cobra.Command, args []string) error {
}
}
statsOptions.StatChan = make(chan []*define.ContainerStats, 1)
+ wg := sync.WaitGroup{}
+ wg.Add(1)
go func() {
for reports := range statsOptions.StatChan {
if err := outputStats(reports); err != nil {
logrus.Error(err)
}
}
+ wg.Done()
+
}()
- return registry.ContainerEngine().ContainerStats(registry.Context(), args, statsOptions)
+ err := registry.ContainerEngine().ContainerStats(registry.Context(), args, statsOptions)
+ wg.Wait()
+ return err
}
func outputStats(reports []*define.ContainerStats) error {