mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-03 21:25:28 +02:00
Implement per-cluster maintenance window for Postgres automatic upgrade (#2710)
* implement maintenance window for major version upgrade * e2e test: fix major version upgrade test and extend with the time window * unit test: add iteration to test isInMaintenanceWindow * UI: show the window and enable edit via UI
This commit is contained in:
@@ -662,3 +662,24 @@ func parseResourceRequirements(resourcesRequirement v1.ResourceRequirements) (ac
|
||||
}
|
||||
return resources, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) isInMainternanceWindow() bool {
|
||||
if c.Spec.MaintenanceWindows == nil {
|
||||
return true
|
||||
}
|
||||
now := time.Now()
|
||||
currentDay := now.Weekday()
|
||||
currentTime := now.Format("15:04")
|
||||
|
||||
for _, window := range c.Spec.MaintenanceWindows {
|
||||
startTime := window.StartTime.Format("15:04")
|
||||
endTime := window.EndTime.Format("15:04")
|
||||
|
||||
if window.Everyday || window.Weekday == currentDay {
|
||||
if currentTime >= startTime && currentTime <= endTime {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user