From b3212a6802b9a9dd5311dcbebe68c9c67fd96218 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 12 Sep 2022 11:15:35 +0200 Subject: set default EventsLogFilePath on first run 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 --- libpod/events.go | 5 +++++ libpod/events/logfile.go | 2 +- libpod/runtime.go | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'libpod') diff --git a/libpod/events.go b/libpod/events.go index ad9c5eafe..2f9799114 100644 --- a/libpod/events.go +++ b/libpod/events.go @@ -3,6 +3,7 @@ package libpod import ( "context" "fmt" + "path/filepath" "sync" "github.com/containers/podman/v4/libpod/events" @@ -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, diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 1b06e22e7..d749a0d4d 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -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() } diff --git a/libpod/runtime.go b/libpod/runtime.go index 03610c687..83c9f53e2 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -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 != "" { -- cgit v1.2.3-54-g00ecf