[health checker] Powercycle after ssh failure
Health checker did not powercycle if there was an error when trying
to initiate a soft reboot command.
Change-Id: If4133c50f11971b02017f6e5d11bb9c3af90baf9
diff --git a/cmd/health_checker/main.go b/cmd/health_checker/main.go
index 907e8ef..629e8f1 100644
--- a/cmd/health_checker/main.go
+++ b/cmd/health_checker/main.go
@@ -136,14 +136,13 @@
func attemptReboot(ctx context.Context, n *netboot.Client, device *devicePkg.DeviceTarget) error {
log.Printf("Attempting reboot for %s", device.Nodename())
- // Attempt to restart the device via serial/SSH.
+ // Attempt to restart the device via serial/SSH. If the restart succeeds,
+ // wait for zedboot to come up. If the restart fails, continue to powercycle.
if err := device.Restart(ctx); err != nil {
- return err
- }
-
- // Wait for Zedboot to come back up. If it comes back up, we're done.
- if err := waitOnZedboot(n, device.Nodename()); err == nil {
- return err
+ log.Printf("Error soft rebooting device: %s", err)
+ } else if err := waitOnZedboot(n, device.Nodename()); err == nil {
+ // Wait for Zedboot to come back up. If it comes back up, we're done.
+ return nil
}
// If we get here, Zedboot never came back up, so we need to powercycle the device.