mirror of
https://github.com/kubereboot/kured.git
synced 2026-08-20 20:06:24 +00:00
* feat: sentinel-command without nsenter by default Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * fix: no readonly mount Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * fix: mount at different folder Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * feat: add signal-reboot Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * feat: make signal configurable and add tests Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * build: rename job Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * cleanup: linter Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * build: also adjust signal manifest Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * test: add e2e-tests Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * fix: small code restructure Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> * fix: adjust version-range Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de> --------- Signed-off-by: Christian Kotzbauer <git@ckotzbauer.de>
35 lines
796 B
Go
35 lines
796 B
Go
package reboot
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// SignalRebootMethod holds context-information for a signal reboot.
|
|
type SignalRebootMethod struct {
|
|
nodeID string
|
|
signal int
|
|
}
|
|
|
|
// NewSignalReboot creates a new signal-rebooter which can run unprivileged.
|
|
func NewSignalReboot(nodeID string, signal int) *SignalRebootMethod {
|
|
return &SignalRebootMethod{nodeID: nodeID, signal: signal}
|
|
}
|
|
|
|
// Reboot triggers the signal-reboot.
|
|
func (c *SignalRebootMethod) Reboot() {
|
|
log.Infof("Emit reboot-signal for node: %s", c.nodeID)
|
|
|
|
process, err := os.FindProcess(1)
|
|
if err != nil {
|
|
log.Fatalf("There was no systemd process found: %v", err)
|
|
}
|
|
|
|
err = process.Signal(syscall.Signal(c.signal))
|
|
if err != nil {
|
|
log.Fatalf("Signal of SIGRTMIN+5 failed: %v", err)
|
|
}
|
|
}
|