mirror of
https://github.com/kubereboot/kured.git
synced 2026-08-28 05:47:23 +00:00
Cleanup checkers
Without this, the checkers are only shell calls: test -f sentinelFile, or sentinelCommand. This changes the behaviour of existing code to test file for sentinelFile checker, and to keep the sentinel command as a command. However, to avoid having validation in the root loop, it moves to use a constructor to cleanup the code. Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
This commit is contained in:
+3
-14
@@ -28,8 +28,6 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
kubectldrain "k8s.io/kubectl/pkg/drain"
|
||||
|
||||
"github.com/google/shlex"
|
||||
|
||||
shoutrrr "github.com/containrrr/shoutrrr"
|
||||
"github.com/kubereboot/kured/pkg/alerts"
|
||||
"github.com/kubereboot/kured/pkg/daemonsetlock"
|
||||
@@ -744,20 +742,11 @@ func root(cmd *cobra.Command, args []string) {
|
||||
var checker checkers.Checker
|
||||
// An override of rebootsentinelcommand means a privileged command
|
||||
if rebootSentinelCommand != "" {
|
||||
log.Infof("Sentinel checker is user provided command: %s", rebootSentinelCommand)
|
||||
cmd, err := shlex.Split(rebootSentinelCommand)
|
||||
if err != nil {
|
||||
log.Fatalf("Error parsing provided sentinel command: %v", err)
|
||||
}
|
||||
checker = checkers.NsEnterRebootChecker{
|
||||
CustomCheckCommand: cmd,
|
||||
NamespacePid: 1,
|
||||
}
|
||||
log.Infof("Sentinel checker is (privileged) user provided command: %s", rebootSentinelCommand)
|
||||
checker = checkers.NewCommandChecker(rebootSentinelCommand)
|
||||
} else {
|
||||
log.Infof("Sentinel checker is (unprivileged) testing for the presence of: %s", rebootSentinelFile)
|
||||
checker = checkers.UnprivilegedRebootChecker{
|
||||
CheckCommand: []string{"test", "-f", rebootSentinelFile},
|
||||
}
|
||||
checker = checkers.NewFileRebootChecker(rebootSentinelFile)
|
||||
}
|
||||
|
||||
go rebootAsRequired(nodeID, rebooter, checker, window, lockTTL, lockReleaseDelay)
|
||||
|
||||
Reference in New Issue
Block a user