Skip to content

Commit

Permalink
handler: refactor Manager's cache options
Browse files Browse the repository at this point in the history
In kubernetes-sigs/controller-runtime#2300 the
`cache.BuilderWithOptions` has been deprecated in favour of cache
options embeded in the Manager.

This PR rewrites our custom cache configuration to use the new way of
configuring it via those new options.
  • Loading branch information
mkowalski committed Oct 19, 2023
1 parent 56700ef commit 04cb53a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func cacheResourcesOnNodes(ctrlOptions *ctrl.Options) {
nodeName := environment.NodeName()
metadataNameMatchingNodeNameSelector := fields.Set{"metadata.name": nodeName}.AsSelector()
nodeLabelMatchingNodeNameSelector := labels.Set{nmstateapi.EnactmentNodeLabel: nodeName}.AsSelector()
ctrlOptions.NewCache = cache.BuilderWithOptions(cache.Options{
SelectorsByObject: cache.SelectorsByObject{

ctrlOptions.Cache = cache.Options{
ByObject: map[client.Object]cache.ByObject{
&corev1.Node{}: {
Field: metadataNameMatchingNodeNameSelector,
},
Expand All @@ -184,7 +185,7 @@ func cacheResourcesOnNodes(ctrlOptions *ctrl.Options) {
Label: nodeLabelMatchingNodeNameSelector,
},
},
})
}
}

func setupHandlerControllers(mgr manager.Manager) error {
Expand Down

0 comments on commit 04cb53a

Please sign in to comment.