Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ARM
k8s
Kured
Commits
793e1a77
Commit
793e1a77
authored
May 15, 2018
by
Frank Vissing
Browse files
adding option to skip rebooting during weekends
parent
b27aaa1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
793e1a77
...
...
@@ -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
...
...
cmd/kured/main.go
View file @
793e1a77
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment