mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
healthcheck: make sure to always show health_status events
This fixes a regression caused by commit 7e6e267329, unfortunately this was not caught during review as for some reason this works fine rootless and only fails as root. Because we set the systemd log level to notice in order to hide the unit started/stopped messages to prevent spamming the journal the issue is that this now also causes systemd to ignore the events we write to journald as we also send them as info level. To fix this we simply send health_status events now on notice level. I decided against sending all events on notice as I think info is fine for them. Whenever the notice level is right is of course debatable but given it may contain the unhealthy message I think having this a notice should be ok. The main reason this made it through testing is because we do not rely on the systemd unit to fire healthchecks in the tests as this is flaky. There is one test were we rely on it though and I added a check there to make sure events are displayed correctly when trigger via systemd. Fixes #20342 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -74,7 +74,19 @@ func (e EventJournalD) Write(ee Event) error {
|
||||
case Volume:
|
||||
m["PODMAN_NAME"] = ee.Name
|
||||
}
|
||||
return journal.Send(ee.ToHumanReadable(false), journal.PriInfo, m)
|
||||
|
||||
// starting with commmit 7e6e267329 we set LogLevel=notice for the systemd healthcheck unit
|
||||
// This so it doesn't log the started/stopped unit messages al the time which spam the
|
||||
// journal if a small interval is used. That however broke the healthcheck event as it no
|
||||
// longer showed up in podman events when running as root as we only send the event on info
|
||||
// level. To fix this we have to send the event on notice level.
|
||||
// https://github.com/containers/podman/issues/20342
|
||||
prio := journal.PriInfo
|
||||
if len(ee.HealthStatus) > 0 {
|
||||
prio = journal.PriNotice
|
||||
}
|
||||
|
||||
return journal.Send(ee.ToHumanReadable(false), prio, m)
|
||||
}
|
||||
|
||||
// Read reads events from the journal and sends qualified events to the event channel
|
||||
|
Reference in New Issue
Block a user