mirror of
https://github.com/kubereboot/kured.git
synced 2026-05-04 23:46:50 +00:00
Remove nodeID from rebooter interface
Without this patch, the rebooter interface has data which is not related to the rebooter interface. This should get removed to make it easier to maintain. The loss comes from the logging, which mentioned the node. In order to not have a regression compared to [1], this ensures that at least the node to be rebooted appears in the main. [1]: https://github.com/kubereboot/kured/pull/134 Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
This commit is contained in:
@@ -7,15 +7,12 @@ import (
|
||||
|
||||
// CommandRebooter holds context-information for a command reboot.
|
||||
type CommandRebooter struct {
|
||||
NodeID string
|
||||
RebootCommand []string
|
||||
}
|
||||
|
||||
// NewCommandReboot creates a new command-rebooter which needs full privileges on the host.
|
||||
|
||||
// Reboot triggers the command-reboot.
|
||||
// Reboot triggers the reboot command
|
||||
func (c CommandRebooter) Reboot() {
|
||||
log.Infof("Running command: %s for node: %s", c.RebootCommand, c.NodeID)
|
||||
log.Infof("Invoking command: %s", c.RebootCommand)
|
||||
if err := util.NewCommand(c.RebootCommand[0], c.RebootCommand[1:]...).Run(); err != nil {
|
||||
log.Fatalf("Error invoking reboot command: %v", err)
|
||||
}
|
||||
|
||||
@@ -9,20 +9,21 @@ import (
|
||||
|
||||
// SignalRebooter holds context-information for a signal reboot.
|
||||
type SignalRebooter struct {
|
||||
NodeID string
|
||||
Signal int
|
||||
}
|
||||
|
||||
// Reboot triggers the reboot signal using SIGTERMIN+5
|
||||
// Reboot triggers the reboot signal
|
||||
func (c SignalRebooter) Reboot() {
|
||||
log.Infof("Emit reboot-signal for node: %s", c.NodeID)
|
||||
log.Infof("Invoking signal: %v", c.Signal)
|
||||
|
||||
process, err := os.FindProcess(1)
|
||||
if err != nil {
|
||||
log.Fatalf("There was no systemd process found: %v", err)
|
||||
log.Fatalf("Not running on Unix: %v", err)
|
||||
}
|
||||
|
||||
err = process.Signal(syscall.Signal(c.Signal))
|
||||
// Either PID does not exist, or the signal does not work. Hoping for
|
||||
// a decent enough error.
|
||||
if err != nil {
|
||||
log.Fatalf("Signal of SIGRTMIN+5 failed: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user