From 528c7bb14b983a63274a54f0868a5dd06c53ec7f Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Thu, 3 Aug 2023 14:46:36 -0600 Subject: [PATCH 1/4] Replaces flag --metrics-port with --metrics-addresss Signed-off-by: Nathan Kinkade --- cmd/kured/main.go | 8 ++++---- kured-ds.yaml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 9af206965..57674bc94 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -47,7 +47,7 @@ var ( drainTimeout time.Duration rebootDelay time.Duration period time.Duration - metricsPort int + metricsAddress string drainGracePeriod int drainPodSelector string skipWaitForDeleteTimeoutSeconds int @@ -126,8 +126,8 @@ func NewRootCommand() *cobra.Command { "node name kured runs on, should be passed down from spec.nodeName via KURED_NODE_ID environment variable") rootCmd.PersistentFlags().BoolVar(&forceReboot, "force-reboot", false, "force a reboot even if the drain fails or times out") - rootCmd.PersistentFlags().IntVar(&metricsPort, "metrics-port", 8080, - "port number where metrics will listen") + rootCmd.PersistentFlags().StringVar(&metricsAddress, "metrics-address", ":8080", + "address where metrics will listen") rootCmd.PersistentFlags().IntVar(&drainGracePeriod, "drain-grace-period", -1, "time in seconds given to each pod to terminate gracefully, if negative, the default value specified in the pod will be used") rootCmd.PersistentFlags().StringVar(&drainPodSelector, "drain-pod-selector", "", @@ -844,5 +844,5 @@ func root(cmd *cobra.Command, args []string) { go maintainRebootRequiredMetric(nodeID, hostSentinelCommand) http.Handle("/metrics", promhttp.Handler()) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", metricsPort), nil)) + log.Fatal(http.ListenAndServe(metricsAddress, nil)) } diff --git a/kured-ds.yaml b/kured-ds.yaml index 615db3d03..71ccb494f 100644 --- a/kured-ds.yaml +++ b/kured-ds.yaml @@ -83,3 +83,4 @@ spec: # - --annotate-nodes=false # - --lock-release-delay=30m # - --log-format=text +# - --metricsAddress=:8080 From 955b79dad2eff6b079793826bdb34df59837c882 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Fri, 4 Aug 2023 14:38:42 -0600 Subject: [PATCH 2/4] Revert "Replaces flag --metrics-port with --metrics-addresss" This reverts commit 528c7bb14b983a63274a54f0868a5dd06c53ec7f. Signed-off-by: Nathan Kinkade --- cmd/kured/main.go | 8 ++++---- kured-ds.yaml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 57674bc94..9af206965 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -47,7 +47,7 @@ var ( drainTimeout time.Duration rebootDelay time.Duration period time.Duration - metricsAddress string + metricsPort int drainGracePeriod int drainPodSelector string skipWaitForDeleteTimeoutSeconds int @@ -126,8 +126,8 @@ func NewRootCommand() *cobra.Command { "node name kured runs on, should be passed down from spec.nodeName via KURED_NODE_ID environment variable") rootCmd.PersistentFlags().BoolVar(&forceReboot, "force-reboot", false, "force a reboot even if the drain fails or times out") - rootCmd.PersistentFlags().StringVar(&metricsAddress, "metrics-address", ":8080", - "address where metrics will listen") + rootCmd.PersistentFlags().IntVar(&metricsPort, "metrics-port", 8080, + "port number where metrics will listen") rootCmd.PersistentFlags().IntVar(&drainGracePeriod, "drain-grace-period", -1, "time in seconds given to each pod to terminate gracefully, if negative, the default value specified in the pod will be used") rootCmd.PersistentFlags().StringVar(&drainPodSelector, "drain-pod-selector", "", @@ -844,5 +844,5 @@ func root(cmd *cobra.Command, args []string) { go maintainRebootRequiredMetric(nodeID, hostSentinelCommand) http.Handle("/metrics", promhttp.Handler()) - log.Fatal(http.ListenAndServe(metricsAddress, nil)) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", metricsPort), nil)) } diff --git a/kured-ds.yaml b/kured-ds.yaml index 71ccb494f..615db3d03 100644 --- a/kured-ds.yaml +++ b/kured-ds.yaml @@ -83,4 +83,3 @@ spec: # - --annotate-nodes=false # - --lock-release-delay=30m # - --log-format=text -# - --metricsAddress=:8080 From f04db81c8191195ecebf8840e92272bde35c645f Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Fri, 4 Aug 2023 14:42:50 -0600 Subject: [PATCH 3/4] Adds new --metrics-host flag The flag --metrics-port already exists. While not as clean, to avoid introducing a backward incompatible change to flags, this commit adds a new --metrics-host flag, which in combination with the existing --metrics-port flag can define a complete listen address for the metrics server as ":" Signed-off-by: Nathan Kinkade --- cmd/kured/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 9af206965..66ee44e6a 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -47,6 +47,7 @@ var ( drainTimeout time.Duration rebootDelay time.Duration period time.Duration + metricsHost string metricsPort int drainGracePeriod int drainPodSelector string @@ -126,6 +127,8 @@ func NewRootCommand() *cobra.Command { "node name kured runs on, should be passed down from spec.nodeName via KURED_NODE_ID environment variable") rootCmd.PersistentFlags().BoolVar(&forceReboot, "force-reboot", false, "force a reboot even if the drain fails or times out") + rootCmd.PersistentFlags().StringVar(&metricsHost, "metrics-host", "", + "host where metrics will listen") rootCmd.PersistentFlags().IntVar(&metricsPort, "metrics-port", 8080, "port number where metrics will listen") rootCmd.PersistentFlags().IntVar(&drainGracePeriod, "drain-grace-period", -1, @@ -844,5 +847,5 @@ func root(cmd *cobra.Command, args []string) { go maintainRebootRequiredMetric(nodeID, hostSentinelCommand) http.Handle("/metrics", promhttp.Handler()) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", metricsPort), nil)) + log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", metricsHost, metricsPort), nil)) } From e5d94c4f13de1739b1503ca54c37dfde4ec92d82 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Fri, 4 Aug 2023 14:48:28 -0600 Subject: [PATCH 4/4] Adds new, commented flags --metrics-{port,host} Signed-off-by: Nathan Kinkade --- kured-ds.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kured-ds.yaml b/kured-ds.yaml index 615db3d03..359253a29 100644 --- a/kured-ds.yaml +++ b/kured-ds.yaml @@ -83,3 +83,5 @@ spec: # - --annotate-nodes=false # - --lock-release-delay=30m # - --log-format=text +# - --metrics-host="" +# - --metrics-port=8080