From 34446f949edf0d8abec99417d7e0df683df20eae Mon Sep 17 00:00:00 2001 From: David Sauer Date: Wed, 6 Jan 2021 21:39:32 +0100 Subject: [PATCH] Allow to disable tainting during pending node reboot by setting the taint name to an empty string. --- cmd/kured/main.go | 2 +- pkg/taints/taints.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/kured/main.go b/cmd/kured/main.go index 9e0a971..7cea012 100644 --- a/cmd/kured/main.go +++ b/cmd/kured/main.go @@ -88,7 +88,7 @@ func main() { rootCmd.PersistentFlags().StringVar(&rebootSentinel, "reboot-sentinel", "/var/run/reboot-required", "path to file whose existence signals need to reboot") rootCmd.PersistentFlags().StringVar(&preferNoScheduleTaintName, "prefer-no-schedule-taint", "weave.works/kured-node-reboot", - "taint name applied during pending node reboot (to prevent receiving additional pods from other rebooting nodes)") + "Taint name applied during pending node reboot (to prevent receiving additional pods from other rebooting nodes). Set to \"\" to disable tainting.") rootCmd.PersistentFlags().StringVar(&slackHookURL, "slack-hook-url", "", "slack hook URL for reboot notfications") diff --git a/pkg/taints/taints.go b/pkg/taints/taints.go index 56dd41e..3796ade 100644 --- a/pkg/taints/taints.go +++ b/pkg/taints/taints.go @@ -32,11 +32,19 @@ func New(client *kubernetes.Clientset, nodeID, taintName string, effect v1.Taint // Enable creates the taint for a node. Creating an existing taint is a noop. func (t *Taint) Enable() { + if t.taintName == "" { + return + } + preferNoSchedule(t.client, t.nodeID, t.taintName, t.effect, true) } // Disable removes the taint for a node. Removing a missing taint is a noop. func (t *Taint) Disable() { + if t.taintName == "" { + return + } + preferNoSchedule(t.client, t.nodeID, t.taintName, t.effect, false) }