Skip to content

Commit

Permalink
[NodeKiller] Schedule reboot and disconnect from node
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzychodzen committed Mar 5, 2020
1 parent ed0941e commit ccec805
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion clusterloader2/pkg/chaos/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,16 @@ func (k *NodeKiller) kill(nodes []v1.Node) {
time.Sleep(time.Duration(k.config.SimulatedDowntime))

klog.Infof("%s: Rebooting %q to repair the node", k, node.Name)
err = util.SSH("sudo reboot", &node, nil)
// Scheduling a reboot in one second, then disconnecting.
//
// Bash command explanation:
// 'nohup' - Making sure that end of SSH connection signal will not break sudo
// 'sudo' - Elevated priviliages, required by 'reboot'
// 'reboot' - Rebooting node
// '+1s' - Parameter to 'reboot', to wait 1 second before rebooting.
// '> /dev/null 2> /dev/null < /dev/null' - File descriptor redirect, as we are closing terminal
// '&' - Execute command in background, end without waiting for result
err = util.SSH("nohup sudo reboot +1s > /dev/null 2> /dev/null < /dev/null &", &node, nil)
if err != nil {
klog.Errorf("%s: Error while rebooting node %q: %v", k, node.Name, err)
return
Expand Down

0 comments on commit ccec805

Please sign in to comment.