Skip to content

Commit

Permalink
Create pod nodeName index always
Browse files Browse the repository at this point in the history
The affinity requires that index as well. Previously the index was only
created if the Kubernikus or ESX integration were enabled.
  • Loading branch information
Nuckal777 committed Feb 2, 2022
1 parent 26b6ee2 commit ac33ddc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ac33ddc

Please sign in to comment.