Skip to content

Commit

Permalink
fix: actually honor 'safe for reboot' condition
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Sep 21, 2023
1 parent 3ce4565 commit 2858d90
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ func (app *ConditionalReboot) Start() {
case group := <-app.rebootRequest:
log.Info().Msgf("Reboot request from group '%s'", group.GetName())

if !IsSafeToReboot() {
log.Warn().Msg("Not safe to reboot (yet), ignoring reboot request")
}

if err := app.audit.Journal(actionToText(group)); err != nil {
log.Err(err).Msg("could not write journal")
}

log.Info().Msg("Trying to reboot...")
if err := app.rebootImpl.Reboot(); err != nil {
RebootErrors.Set(1)
log.Error().Err(err).Msg("reboot failed")
if IsSafeToReboot() {
log.Info().Msg("Trying to reboot...")
if err := app.audit.Journal(actionToText(group)); err != nil {
log.Err(err).Msg("could not write journal")
}

if err := app.rebootImpl.Reboot(); err != nil {
RebootErrors.Set(1)
log.Error().Err(err).Msg("Reboot failed")
} else {
log.Info().Msgf("Cancelling")
cancel()
time.Sleep(5 * time.Second)
}
} else {
log.Info().Msgf("Cancelling")
cancel()
time.Sleep(5 * time.Second)
log.Warn().Msg("Not safe to reboot (yet), ignoring reboot request")
}
}
}
Expand Down

0 comments on commit 2858d90

Please sign in to comment.