Merge pull request #23170 from Luap99/events

podman events: fix error race
This commit is contained in:
openshift-merge-bot[bot]
2024-07-05 07:02:47 +00:00
committed by GitHub

View File

@ -163,6 +163,7 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
go func() {
errChannel <- registry.ContainerEngine().Events(context.Background(), eventOptions)
close(errChannel)
}()
for {
@ -170,14 +171,8 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
case event, ok := <-eventChannel:
if !ok {
// channel was closed we can exit
select {
case err := <-errChannel:
if err != nil {
return err
}
default:
}
return nil
// read the error channel blocking to make sure we are not missing any errors (#23165)
return <-errChannel
}
switch {
case doJSON: