make --syslog errors non fatal

Podman will always pass down --syslog to conmon since 13c2aca21.
However there systems without syslog running, likely in container
setups. As reported in this was already a problem before when debug
level is used. Then conmon will pass down --syslog back to the podman
container cleanup command causing it to fail without doing anything.
Given that I think it is better to just ignore the error and log it on
debug level, we need to make sure cleanup works consistently.

[NO NEW TESTS NEEDED]

Fixes #19075

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-07-10 11:36:28 +02:00
parent b713fe3997
commit 3f8ee70d0c

View File

@ -4,9 +4,7 @@
package main package main
import ( import (
"fmt"
"log/syslog" "log/syslog"
"os"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
logrusSyslog "github.com/sirupsen/logrus/hooks/syslog" logrusSyslog "github.com/sirupsen/logrus/hooks/syslog"
@ -19,10 +17,8 @@ func syslogHook() {
hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "") hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
if err != nil { if err != nil {
fmt.Fprint(os.Stderr, "Failed to initialize syslog hook: "+err.Error()) logrus.Debug("Failed to initialize syslog hook: " + err.Error())
os.Exit(1) } else {
}
if err == nil {
logrus.AddHook(hook) logrus.AddHook(hook)
} }
} }