mirror of
https://github.com/outbackdingo/incus-os.git
synced 2026-01-27 10:19:24 +00:00
incus-osd: Adjust update sleep logic to choose the minimum of the configured frequency and start of next maintenance window
Signed-off-by: Mathias Gibbens <mathias.gibbens@futurfusion.io>
This commit is contained in:
@@ -573,8 +573,19 @@ func updateChecker(ctx context.Context, s *state.State, t *tui.TUI, p providers.
|
||||
break
|
||||
}
|
||||
|
||||
// If any maintenance windows are defined, limit the time to sleep to be a minimum
|
||||
// of the configured check frequency and the start of the next maintenance window,
|
||||
// whichever is shorter.
|
||||
for _, window := range s.System.Update.Config.MaintenanceWindows {
|
||||
if window.TimeUntilActive() > 0 && window.TimeUntilActive() < frequency {
|
||||
frequency = window.TimeUntilActive()
|
||||
}
|
||||
}
|
||||
|
||||
if timeSinceCheck < frequency {
|
||||
time.Sleep(frequency - timeSinceCheck)
|
||||
// Add one minute to the calculated sleep to protect against an edge case
|
||||
// where we try to do an update check right at the start of a maintenance window.
|
||||
time.Sleep(frequency - timeSinceCheck + 1*time.Minute)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user