From ac33ddc58644feb9f32ec870e476ef41fd936cc0 Mon Sep 17 00:00:00 2001 From: D074096 Date: Wed, 2 Feb 2022 15:53:55 +0100 Subject: [PATCH] Create pod nodeName index always The affinity requires that index as well. Previously the index was only created if the Kubernikus or ESX integration were enabled. --- main.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index dcd6622..9c90008 100644 --- a/main.go +++ b/main.go @@ -142,17 +142,16 @@ func setupReconcilers(mgr manager.Manager, enableESXMaintenance bool, enableKube return fmt.Errorf("Failed to setup maintenance controller node reconciler: %w", err) } - if enableKubernikusMaintenance || enableESXMaintenance { - err := mgr.GetFieldIndexer().IndexField(context.Background(), - &v1.Pod{}, - "spec.nodeName", - func(o client.Object) []string { - pod := o.(*v1.Pod) // nolint:forcetypeassert - return []string{pod.Spec.NodeName} - }) - if err != nil { - return fmt.Errorf("Unable to create index spec.nodeName on pod resource: %w", err) - } + // Required for affinity check plugin as well as kubernikus and ESX integration + err := mgr.GetFieldIndexer().IndexField(context.Background(), + &v1.Pod{}, + "spec.nodeName", + func(o client.Object) []string { + pod := o.(*v1.Pod) // nolint:forcetypeassert + return []string{pod.Spec.NodeName} + }) + if err != nil { + return fmt.Errorf("Unable to create index spec.nodeName on pod resource: %w", err) } if enableKubernikusMaintenance {