From 0619e04f8f494dbacef34abdb9a8a1b9d764f53c Mon Sep 17 00:00:00 2001 From: Geoffrey Beausire Date: Thu, 3 Oct 2024 14:14:06 +0200 Subject: [PATCH] Fix node-disruption-types containing empty strings (#72) Split was containing empty string. Now we filter them out to avoid rejecting maintenances. --- cmd/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index d8a677b..0a059cd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -57,7 +57,7 @@ func main() { var rejectEmptyNodeDisruption bool var retryInterval time.Duration var rejectOverlappingDisruption bool - var nodeDisruptionTypes string + var nodeDisruptionTypesRaw string flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, @@ -66,7 +66,7 @@ func main() { flag.BoolVar(&rejectEmptyNodeDisruption, "reject-empty-node-disruption", false, "Reject NodeDisruption matching no actual node.") flag.DurationVar(&retryInterval, "retry-interval", controller.DefaultRetryInterval, "How long to wait between each retry (Default 60s)") flag.BoolVar(&rejectOverlappingDisruption, "reject-overlapping-disruption", false, "Automatically reject any overlapping NodeDisruption (based on node selector), preserving the oldest one") - flag.StringVar(&nodeDisruptionTypes, "node-disruption-types", "", "The list of types allowed for a node disruption separated by a comma.") + flag.StringVar(&nodeDisruptionTypesRaw, "node-disruption-types", "", "The list of types allowed for a node disruption separated by a comma.") opts := zap.Options{ Development: true, @@ -100,6 +100,8 @@ func main() { os.Exit(1) } + nodeDisruptionTypes := strings.FieldsFunc(nodeDisruptionTypesRaw, func(c rune) bool { return c == ',' }) + if err = (&controller.NodeDisruptionReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -107,7 +109,7 @@ func main() { RejectEmptyNodeDisruption: rejectEmptyNodeDisruption, RetryInterval: retryInterval, RejectOverlappingDisruption: rejectOverlappingDisruption, - NodeDisruptionTypes: strings.Split(nodeDisruptionTypes, ","), + NodeDisruptionTypes: nodeDisruptionTypes, }, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "NodeDisruption")