Skip to content

Commit

Permalink
libpod: runtime newEventer() cleanup
Browse files Browse the repository at this point in the history
There is no reason to create a new eventer every time. The libpod runtime
already has one attached which should be used instead.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 12, 2022
1 parent 76980a2 commit cd32b92
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions libpod/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ 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(ctx context.Context, options events.ReadOptions) error {
eventer, err := r.newEventer()
if err != nil {
return err
}
return eventer.Read(ctx, options)
return r.eventer.Read(ctx, options)
}

// GetEvents reads the event log and returns events based on input filters
Expand All @@ -149,10 +145,6 @@ func (r *Runtime) GetEvents(ctx context.Context, filters []string) ([]*events.Ev
FromStart: true,
Stream: false,
}
eventer, err := r.newEventer()
if err != nil {
return nil, err
}

logEvents := make([]*events.Event, 0, len(eventChannel))
readLock := sync.Mutex{}
Expand All @@ -164,7 +156,7 @@ func (r *Runtime) GetEvents(ctx context.Context, filters []string) ([]*events.Ev
readLock.Unlock()
}()

readErr := eventer.Read(ctx, options)
readErr := r.eventer.Read(ctx, options)
readLock.Lock() // Wait for the events to be consumed.
return logEvents, readErr
}
Expand Down

0 comments on commit cd32b92

Please sign in to comment.