diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index de5a66dee1..dc305fabfd 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -15,7 +15,6 @@ import ( "github.com/containers/podman/v4/libpod/events" "github.com/containers/podman/v4/libpod/logs" "github.com/containers/podman/v4/pkg/rootless" - "github.com/coreos/go-systemd/v22/journal" "github.com/coreos/go-systemd/v22/sdjournal" "github.com/sirupsen/logrus" ) @@ -32,21 +31,6 @@ func init() { logDrivers = append(logDrivers, define.JournaldLogging) } -// initializeJournal will write an empty string to the journal -// when a journal is created. This solves a problem when people -// attempt to read logs from a container that has never had stdout/stderr -func (c *Container) initializeJournal(ctx context.Context) error { - m := make(map[string]string) - m["SYSLOG_IDENTIFIER"] = "podman" - m["PODMAN_ID"] = c.ID() - history := events.History - m["PODMAN_EVENT"] = history.String() - container := events.Container - m["PODMAN_TYPE"] = container.String() - m["PODMAN_TIME"] = time.Now().Format(time.RFC3339Nano) - return journal.Send("", journal.PriInfo, m) -} - func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOptions, logChannel chan *logs.LogLine, colorID int64) error { // We need the container's events in the same journal to guarantee // consistency, see #10323. diff --git a/libpod/container_log_unsupported.go b/libpod/container_log_unsupported.go index bb74a810d5..cdce820b4f 100644 --- a/libpod/container_log_unsupported.go +++ b/libpod/container_log_unsupported.go @@ -14,7 +14,3 @@ import ( func (c *Container) readFromJournal(_ context.Context, _ *logs.LogOptions, _ chan *logs.LogLine, colorID int64) error { return fmt.Errorf("journald logging only enabled with systemd on linux: %w", define.ErrOSNotSupported) } - -func (c *Container) initializeJournal(ctx context.Context) error { - return fmt.Errorf("journald logging only enabled with systemd on linux: %w", define.ErrOSNotSupported) -} diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index caa4a2c7a1..2ff9dfb280 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -541,12 +541,8 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai } switch ctr.config.LogDriver { - case define.NoLogging, define.PassthroughLogging: + case define.NoLogging, define.PassthroughLogging, define.JournaldLogging: break - case define.JournaldLogging: - if err := ctr.initializeJournal(ctx); err != nil { - return nil, fmt.Errorf("failed to initialize journal: %w", err) - } default: if ctr.config.LogPath == "" { ctr.config.LogPath = filepath.Join(ctr.config.StaticDir, "ctr.log")