Skip to content

Commit

Permalink
Fix default watchdog timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Sluiter <[email protected]>
  • Loading branch information
slintes committed Jun 18, 2024
1 parent fb6013b commit 5cccd20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pkg/reboot/calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ func (r *calculator) GetRebootDuration(k8sClient client.Client, ctx context.Cont
return 0, errors.New("SelfNodeRemediationConfig not set yet, can't calculate minimum reboot duration")
}

watchdogTimeout := utils.GetWatchdogTimeout(node)
watchdogTimeout, err := utils.GetWatchdogTimeout(node)
if err != nil {
// 60s is the maximum default watchdog timeout according to https://docs.kernel.org/watchdog/watchdog-parameters.html
defaultWatchdogTimeout := 60 * time.Second
r.log.Error(err, "failed to get watchdog timeout from node annotations, will use the default timeout", "node", node.Name, "default timeout in seconds", defaultWatchdogTimeout.Seconds())
watchdogTimeout = defaultWatchdogTimeout
}
minimumCalculatedRebootDuration, err := r.calculateMinimumRebootDuration(k8sClient, ctx, watchdogTimeout)
if err != nil {
return 0, errors.Wrap(err, "failed to calculate minimum reboot duration")
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func IsSoftwareRebootEnabled() (bool, error) {
return softwareRebootEnabled, nil
}

func GetWatchdogTimeout(node *v1.Node) time.Duration {
func GetWatchdogTimeout(node *v1.Node) (time.Duration, error) {
if node.Annotations == nil {
return 0
return 0, errors.New("node has no annotations")
}

timeout, err := strconv.Atoi(node.Annotations[WatchdogTimeoutSecondsAnnotation])
if err != nil {
return 0
return 0, errors.Wrapf(err, "failed to convert watchdog timeout to int. value is: %s", node.Annotations[WatchdogTimeoutSecondsAnnotation])
}

return time.Duration(timeout) * time.Second
return time.Duration(timeout) * time.Second, nil
}

0 comments on commit 5cccd20

Please sign in to comment.