Skip to content

Commit

Permalink
Fix node-disruption-types containing empty strings
Browse files Browse the repository at this point in the history
Split was containing empty string. Now we filter them out
to avoid rejecting maintenances.
  • Loading branch information
geobeau committed Oct 3, 2024
1 parent bf78b8e commit 677fb18
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -100,14 +100,16 @@ 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(),
Config: controller.NodeDisruptionReconcilerConfig{
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")
Expand Down

0 comments on commit 677fb18

Please sign in to comment.