fix race where podman events exits to early
In order to display all events we have to read until the event channel is closed. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
b3212a6802
commit
2ae4ce7999
|
@ -101,12 +101,12 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case err := <-errChannel:
|
case event, ok := <-eventChannel:
|
||||||
return err
|
if !ok {
|
||||||
case event := <-eventChannel:
|
// channel was closed we can exit
|
||||||
|
return nil
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case event == nil:
|
|
||||||
// no-op
|
|
||||||
case doJSON:
|
case doJSON:
|
||||||
jsonStr, err := event.ToJSONString()
|
jsonStr, err := event.ToJSONString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -121,6 +121,12 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
|
||||||
default:
|
default:
|
||||||
fmt.Println(event.ToHumanReadable(!noTrunc))
|
fmt.Println(event.ToHumanReadable(!noTrunc))
|
||||||
}
|
}
|
||||||
|
case err := <-errChannel:
|
||||||
|
// only exit in case of an error,
|
||||||
|
// otherwise keep reading events until the event channel is closed
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ load helpers
|
||||||
.*image tag $imageID $tag
|
.*image tag $imageID $tag
|
||||||
.*image untag $imageID $tag:latest
|
.*image untag $imageID $tag:latest
|
||||||
.*image tag $imageID $tag
|
.*image tag $imageID $tag
|
||||||
|
.*image untag $imageID $IMAGE
|
||||||
.*image untag $imageID $tag:latest
|
.*image untag $imageID $tag:latest
|
||||||
.*image remove $imageID $imageID" \
|
.*image remove $imageID $imageID" \
|
||||||
"podman events"
|
"podman events"
|
||||||
|
|
Loading…
Reference in New Issue