Commit 91bf84a9 authored by Adam Harrison's avatar Adam Harrison
Browse files

Convert period arg to time.Duration

parent 4e4b6f06
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
var ( var (
version = "unreleased" version = "unreleased"
period int period time.Duration
dsNamespace string dsNamespace string
dsName string dsName string
lockAnnotation string lockAnnotation string
...@@ -38,8 +38,8 @@ func main() { ...@@ -38,8 +38,8 @@ func main() {
Short: "Kubernetes Reboot Daemon", Short: "Kubernetes Reboot Daemon",
Run: root} Run: root}
rootCmd.PersistentFlags().IntVar(&period, "period", 60, rootCmd.PersistentFlags().DurationVar(&period, "period", time.Minute*60,
"reboot check period in minutes") "reboot check period")
rootCmd.PersistentFlags().StringVar(&dsNamespace, "ds-name", "kube-system", rootCmd.PersistentFlags().StringVar(&dsNamespace, "ds-name", "kube-system",
"namespace containing daemonset on which to place lock") "namespace containing daemonset on which to place lock")
rootCmd.PersistentFlags().StringVar(&dsName, "ds-namespace", "kured", rootCmd.PersistentFlags().StringVar(&dsName, "ds-namespace", "kured",
...@@ -219,7 +219,7 @@ func root(cmd *cobra.Command, args []string) { ...@@ -219,7 +219,7 @@ func root(cmd *cobra.Command, args []string) {
log.Infof("Node ID: %s", nodeID) log.Infof("Node ID: %s", nodeID)
log.Infof("Lock Annotation: %s/%s:%s", dsNamespace, dsName, lockAnnotation) log.Infof("Lock Annotation: %s/%s:%s", dsNamespace, dsName, lockAnnotation)
log.Infof("Reboot Sentinel: %s every %d minutes", rebootSentinel, period) log.Infof("Reboot Sentinel: %s every %v", rebootSentinel, period)
config, err := rest.InClusterConfig() config, err := rest.InClusterConfig()
if err != nil { if err != nil {
...@@ -242,7 +242,7 @@ func root(cmd *cobra.Command, args []string) { ...@@ -242,7 +242,7 @@ func root(cmd *cobra.Command, args []string) {
} }
source := rand.NewSource(time.Now().UnixNano()) source := rand.NewSource(time.Now().UnixNano())
tick := delaytick.New(source, time.Minute*time.Duration(period)) tick := delaytick.New(source, period)
for _ = range tick { for _ = range tick {
if rebootRequired() && !rebootBlocked() { if rebootRequired() && !rebootBlocked() {
node, err := client.CoreV1().Nodes().Get(nodeID) node, err := client.CoreV1().Nodes().Get(nodeID)
......
...@@ -20,7 +20,7 @@ spec: ...@@ -20,7 +20,7 @@ spec:
# - --ds-name=kube-system # - --ds-name=kube-system
# - --ds-namespace=kured # - --ds-namespace=kured
# - --lock-annotation=weave.works/kured-node-lock # - --lock-annotation=weave.works/kured-node-lock
# - --period=60 # - --period=1h
# - --prometheus-url=http://prometheus.monitoring.svc.cluster.local # - --prometheus-url=http://prometheus.monitoring.svc.cluster.local
# - --reboot-sentinel=/var/run/reboot-required # - --reboot-sentinel=/var/run/reboot-required
# - --slack-hook-url=https://hooks.slack.com/... # - --slack-hook-url=https://hooks.slack.com/...
......
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