fix switchover schedule tests (#2995)

* fix switchover schedule tests

Previously the tests would fail depending on the local time zone and the
time of day the test was being run.

---------

Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
Co-authored-by: Mikkel Oscar Lyderik Larsen <mikkeloscar@users.noreply.github.com>
This commit is contained in:
Steven Berler
2025-12-11 10:22:40 +01:00
committed by GitHub
co-authored by Felix Kunde Mikkel Oscar Lyderik Larsen
parent 5aa8f961ec
commit cd05682482
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -1767,9 +1767,13 @@ func (c *Cluster) GetStatus() *ClusterStatus {
}
func (c *Cluster) GetSwitchoverSchedule() string {
now := time.Now().UTC()
return c.getSwitchoverScheduleAtTime(now)
}
func (c *Cluster) getSwitchoverScheduleAtTime(now time.Time) string {
var possibleSwitchover, schedule time.Time
now := time.Now().UTC()
for _, window := range c.Spec.MaintenanceWindows {
// in the best case it is possible today
possibleSwitchover = time.Date(now.Year(), now.Month(), now.Day(), window.StartTime.Hour(), window.StartTime.Minute(), 0, 0, time.UTC)