close journald when reading

when reading from journald, we need to close the journal handler for
events and logging.

Fixes: #8864

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude 2021-01-04 09:32:18 -06:00
parent f261bfc549
commit 002d0d6ee6

View file

@ -84,7 +84,11 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
if err != nil {
return err
}
defer func() {
if err := j.Close(); err != nil {
logrus.Errorf("Unable to close journal :%v", err)
}
}()
// match only podman journal entries
podmanJournal := sdjournal.Match{Field: "SYSLOG_IDENTIFIER", Value: "podman"}
if err := j.AddMatch(podmanJournal.String()); err != nil {
@ -112,7 +116,6 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
if err != nil {
return errors.Wrap(err, "failed to get journal cursor")
}
for {
select {
case <-ctx.Done():