Skip to content

Commit

Permalink
set default EventsLogFilePath on first run
Browse files Browse the repository at this point in the history
The current code only sets EventsLogFilePath when the tmp is overwritten
from the db. We should always set the default when no path was set in
containers.conf.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 12, 2022
1 parent 12a1483 commit b3212a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions libpod/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package libpod
import (
"context"
"fmt"
"path/filepath"
"sync"

"github.com/containers/podman/v4/libpod/events"
Expand All @@ -11,6 +12,10 @@ import (

// newEventer returns an eventer that can be used to read/write events
func (r *Runtime) newEventer() (events.Eventer, error) {
if r.config.Engine.EventsLogFilePath == "" {
// default, use path under tmpdir when none was explicitly set by the user
r.config.Engine.EventsLogFilePath = filepath.Join(r.config.Engine.TmpDir, "events", "events.log")
}
options := events.EventerOptions{
EventerType: r.config.Engine.EventsLogger,
LogFilePath: r.config.Engine.EventsLogFilePath,
Expand Down
2 changes: 1 addition & 1 deletion libpod/events/logfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newLogFileEventer(options EventerOptions) (*EventLogFile, error) {
// https://github.com/containers/podman/issues/15688
fd, err := os.OpenFile(options.LogFilePath, os.O_RDONLY|os.O_CREATE, 0700)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to create event log file: %w", err)
}
return &EventLogFile{options: options}, fd.Close()
}
Expand Down
3 changes: 0 additions & 3 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,6 @@ func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) {
logrus.Debugf("Overriding tmp dir %q with %q from database", c.TmpDir, dbConfig.LibpodTmp)
}
c.TmpDir = dbConfig.LibpodTmp
if c.EventsLogFilePath == "" {
c.EventsLogFilePath = filepath.Join(dbConfig.LibpodTmp, "events", "events.log")
}
}

if !r.storageSet.VolumePathSet && dbConfig.VolumePath != "" {
Expand Down

0 comments on commit b3212a6

Please sign in to comment.