diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-07-02 12:36:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 12:36:04 -0400 |
commit | 22def2e2d98fd2ac4f6709bd094ee66bda9c648b (patch) | |
tree | 7e795ae88a3df174bb7d399a115c2178ec4fd93b /libpod/events.go | |
parent | c131567401bea2867d597d79cce75b99012e64fb (diff) | |
parent | 9e4cf6ca513fa0646f33ade14955e1fc4335e176 (diff) | |
download | podman-22def2e2d98fd2ac4f6709bd094ee66bda9c648b.tar.gz podman-22def2e2d98fd2ac4f6709bd094ee66bda9c648b.tar.bz2 podman-22def2e2d98fd2ac4f6709bd094ee66bda9c648b.zip |
Merge pull request #6838 from mheon/fix_panic_events
Fix `system service` panic from early hangup in events
Diffstat (limited to 'libpod/events.go')
-rw-r--r-- | libpod/events.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libpod/events.go b/libpod/events.go index 3d07c5d76..b587f1697 100644 --- a/libpod/events.go +++ b/libpod/events.go @@ -1,6 +1,7 @@ package libpod import ( + "context" "fmt" "github.com/containers/libpod/libpod/events" @@ -75,16 +76,16 @@ func (v *Volume) newVolumeEvent(status events.Status) { // Events is a wrapper function for everyone to begin tailing the events log // with options -func (r *Runtime) Events(options events.ReadOptions) error { +func (r *Runtime) Events(ctx context.Context, options events.ReadOptions) error { eventer, err := r.newEventer() if err != nil { return err } - return eventer.Read(options) + return eventer.Read(ctx, options) } // GetEvents reads the event log and returns events based on input filters -func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) { +func (r *Runtime) GetEvents(ctx context.Context, filters []string) ([]*events.Event, error) { var readErr error eventChannel := make(chan *events.Event) options := events.ReadOptions{ @@ -98,7 +99,7 @@ func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) { return nil, err } go func() { - readErr = eventer.Read(options) + readErr = eventer.Read(ctx, options) }() if readErr != nil { return nil, readErr @@ -112,7 +113,7 @@ func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) { // GetLastContainerEvent takes a container name or ID and an event status and returns // the last occurrence of the container event -func (r *Runtime) GetLastContainerEvent(nameOrID string, containerEvent events.Status) (*events.Event, error) { +func (r *Runtime) GetLastContainerEvent(ctx context.Context, nameOrID string, containerEvent events.Status) (*events.Event, error) { // check to make sure the event.Status is valid if _, err := events.StringToStatus(containerEvent.String()); err != nil { return nil, err @@ -122,7 +123,7 @@ func (r *Runtime) GetLastContainerEvent(nameOrID string, containerEvent events.S fmt.Sprintf("event=%s", containerEvent), "type=container", } - containerEvents, err := r.GetEvents(filters) + containerEvents, err := r.GetEvents(ctx, filters) if err != nil { return nil, err } |