-
Notifications
You must be signed in to change notification settings - Fork 821
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
使用search查询资源失败(资源存在) #2226
Comments
like this issue #1946 |
使用的是push模式不是pull模式
|
|
yaml文件如下:
如下资源非kubernetes原生为自定义crd资源
|
The fail is I used dynamic RESTMapper to dynamically discover resource types at runtime, this seems to be the problem with usage, I try to fix it |
Hi @first-sight12, have you installed this crd |
No,On the k8s host |
@first-sight12 @luoMonkeyKing |
now restMapper discovers resource type only from controller panel. So only resources installed in karmada apiserver can be searched. I think we shall discover it from all the member clusters. |
How about it. Guess the kind when NoMatchError occur. It's a quick fix, but not eventually. diff --git a/pkg/search/controller.go b/pkg/search/controller.go
index edb6fddd..3b1b950f 100644
--- a/pkg/search/controller.go
+++ b/pkg/search/controller.go
@@ -427,8 +427,13 @@ func (c *Controller) getResources(selectors []searchv1alpha1.ResourceSelector) [
c.restMapper, schema.FromAPIVersionAndKind(rs.APIVersion, rs.Kind),
)
if err != nil {
- klog.Errorf("failed to get gvr: %v", err)
- continue
+ if !meta.IsNoMatchError(err) {
+ klog.Errorf("failed to get gvr: %v", err)
+ continue
+ }
+ gvk := schema.FromAPIVersionAndKind(rs.APIVersion, rs.Kind)
+ gvr, _ = meta.UnsafeGuessKindToResource(gvk)
+ klog.Warningf("guess kind of %v as %v", gvk.String(), gvr.String())
}
resources = append(resources, gvr)
} |
Hi @ikaven1024, I discussed this with @liys87x earlier: #2361 (comment) How can we ensure correct resource gvr? |
Yes, it's unsafe, but solving most cases. It's a temporary solution before finding a perfect one. |
The prerequisite for guessing resource names using this Maybe we can ask for some other comments. @liys87x @RainbowMango @huntsman-li |
What happened:
转发到单个集群(member1)能够查到资源,结果如下:
使用search查询为空(有时能查到结果 有时查询为空),结果如下:
karmada-search 日志如下:
What you expected to happen:
期望search查询结果与单集群转发结果一致
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
kubectl-karmada version
orkarmadactl version
):The text was updated successfully, but these errors were encountered: