Commit 793e1a77 authored by Frank Vissing's avatar Frank Vissing
Browse files

adding option to skip rebooting during weekends

parent b27aaa1b
......@@ -70,6 +70,7 @@ Flags:
--reboot-sentinel string path to file whose existence signals need to reboot (default "/var/run/reboot-required")
--slack-hook-url string slack hook URL for reboot notfications
--slack-username string slack username for reboot notfications (default "kured")
--no-weekends-reboot bool option to not restart during weekends (default "false")
```
### Reboot Sentinel File & Period
......
......@@ -26,15 +26,16 @@ var (
version = "unreleased"
// Command line flags
period time.Duration
dsNamespace string
dsName string
lockAnnotation string
prometheusURL string
alertFilter *regexp.Regexp
rebootSentinel string
slackHookURL string
slackUsername string
period time.Duration
dsNamespace string
dsName string
lockAnnotation string
prometheusURL string
alertFilter *regexp.Regexp
rebootSentinel string
slackHookURL string
slackUsername string
noWeekendReboot bool
// Metrics
rebootRequiredGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
......@@ -73,6 +74,7 @@ func main() {
"slack hook URL for reboot notfications")
rootCmd.PersistentFlags().StringVar(&slackUsername, "slack-username", "kured",
"slack username for reboot notfications")
rootCmd.PersistentFlags().BoolVar(&noWeekendReboot, "no-weekends-reboot", false, "if true no reboots will be performed during weekends")
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
......@@ -122,6 +124,11 @@ func rebootRequired() bool {
func rebootBlocked() bool {
if prometheusURL != "" {
alertNames, err := alerts.PrometheusActiveAlerts(prometheusURL, alertFilter)
weekday := time.Now().Weekday()
if noWeekendReboot && (int(weekday) == 0 || int(weekday) == 6) {
log.Warnf("Reboot blocked: day of week: %v",weekday)
return true
}
if err != nil {
log.Warnf("Reboot blocked: prometheus query error: %v", err)
return true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment