From 16dc5e30d9064c2a2dc66969eea6298f89b93447 Mon Sep 17 00:00:00 2001 From: Christian Kotzbauer Date: Wed, 2 Aug 2023 19:04:52 +0200 Subject: [PATCH] fix: log on unusual sentinel-command exit code (#806) Signed-off-by: Christian Kotzbauer --- cmd/kured/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 794be26b0..9af206965 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -315,7 +315,8 @@ func buildHostCommand(pid int, command []string) []string { } func rebootRequired(sentinelCommand []string) bool { - if err := newCommand(sentinelCommand[0], sentinelCommand[1:]...).Run(); err != nil { + cmd := newCommand(sentinelCommand[0], sentinelCommand[1:]...) + if err := cmd.Run(); err != nil { switch err := err.(type) { case *exec.ExitError: // We assume a non-zero exit code means 'reboot not required', but of course @@ -323,6 +324,9 @@ func rebootRequired(sentinelCommand []string) bool { // went wrong during its execution. In that case, not entering a reboot loop // is the right thing to do, and we are logging stdout/stderr of the command // so it should be obvious what is wrong. + if cmd.ProcessState.ExitCode() != 1 { + log.Warnf("sentinel command ended with unexpected exit code: %v", cmd.ProcessState.ExitCode()) + } return false default: // Something was grossly misconfigured, such as the command path being wrong.