-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"non-exact field matches are not supported by the cache" when using fieldSelector with not exact fields #612
Comments
it's unclear to me how we'd support this w/o becoming fairly complicated. /kind feature |
In case anyone else lands here from KubeBuilder and wants an workaround I was able to create a directClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme(), Mapper: mgr.GetRESTMapper()})
if err != nil {
panic(err)
} |
Another option is to use the |
📖 Elaborate on the design pricipals of KB
/kind design |
figured out another approach:
eg:
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Walk the returned list to verify the binding matches the expect type and name. In order to use the MatchingFields with the caching Client, an IndexField first needs to be created. However, we need to match multiple fields, but controller-runtime only supports one field easily: kubernetes-sigs/controller-runtime#612 The expected number of bindings per namespace isn't very many, so it is unlikely there is much to gain with an index. The fake client doesn't support MatchingFields, and we didn't have a negative test so this otherwise went unnoticed until the FSS was flipped.
Walk the returned list to verify the binding matches the expect type and name. In order to use the MatchingFields with the caching Client, an IndexField first needs to be created. However, we need to match multiple fields, but controller-runtime only supports one field easily: kubernetes-sigs/controller-runtime#612 The expected number of bindings per namespace isn't very many, so it is unlikely there is much to gain with an index. The fake client doesn't support MatchingFields, and we didn't have a negative test so this otherwise went unnoticed until the FSS was flipped.
@sarjeet2013 I'm trying to do the same thing you are here (same field selector). Were you able to find a workaround? I have tried the suggestions in the comments, but I think I am going to have to directly hit the API to get this to work. It seems that fields selectors with multiple fields simply do not work. I have added the proper field indexers to my manager: nodeNameIndexFunc := func(obj client.Object) []string {
return []string{obj.(*v1.Pod).Spec.NodeName}
}
if err = mgr.GetFieldIndexer().IndexField(context.Background(), &v1.Pod{}, "spec.nodeName", nodeNameIndexFunc); err != nil {
glog.Fatalf("unable to set up field indexer for spec.nodeName: %v", err)
}
phaseIndexFunc := func(obj client.Object) []string {
return []string{string(obj.(*v1.Pod).Status.Phase)}
}
if err = mgr.GetFieldIndexer().IndexField(context.Background(), &v1.Pod{}, "status.phase", phaseIndexFunc); err != nil {
glog.Fatalf("unable to set up field indexer for status.phase: %v", err)
} And I still face the same error as you: |
/reopen |
@kscharm: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Exactly caused by Line#192: controller-runtime/pkg/cache/internal/cache_reader.go Lines 190 to 200 in 386c2b5
And a TODO is here Line#117: controller-runtime/pkg/cache/internal/cache_reader.go Lines 108 to 126 in 386c2b5
|
Walk the returned list to verify the binding matches the expect type and name. In order to use the MatchingFields with the caching Client, an IndexField first needs to be created. However, we need to match multiple fields, but controller-runtime only supports one field easily: kubernetes-sigs/controller-runtime#612 The expected number of bindings per namespace isn't very many, so it is unlikely there is much to gain with an index. The fake client doesn't support MatchingFields, and we didn't have a negative test so this otherwise went unnoticed until the FSS was flipped.
Walk the returned list to verify the binding matches the expect type and name. In order to use the MatchingFields with the caching Client, an IndexField first needs to be created. However, we need to match multiple fields, but controller-runtime only supports one field easily: kubernetes-sigs/controller-runtime#612 The expected number of bindings per namespace isn't very many, so it is unlikely there is much to gain with an index. The fake client doesn't support MatchingFields, and we didn't have a negative test so this otherwise went unnoticed until the FSS was flipped.
Walk the returned list to verify the binding matches the expect type and name. In order to use the MatchingFields with the caching Client, an IndexField first needs to be created. However, we need to match multiple fields, but controller-runtime only supports one field easily: kubernetes-sigs/controller-runtime#612 The expected number of bindings per namespace isn't very many, so it is unlikely there is much to gain with an index. The fake client doesn't support MatchingFields, and we didn't have a negative test so this otherwise went unnoticed until the FSS was flipped.
I am getting the following error when trying to get list of pods with their state filetered with fieldSelector.
"error":"non-exact field matches are not supported by the cache"
Here is the sample code:
This look like a current limitation and not supported. See https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/cache/internal/cache_reader.go#L99
The text was updated successfully, but these errors were encountered: