mirror of
https://github.com/containers/podman.git
synced 2025-07-25 09:05:00 +08:00
Merge pull request #17547 from Luap99/no-init-journal
journald: remove initializeJournal()
This commit is contained in:
@ -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.
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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")
|
||||
|
Reference in New Issue
Block a user