feat: Introduce SearchQuery API and Refine Indexing Infrastructure#50
feat: Introduce SearchQuery API and Refine Indexing Infrastructure#50JoseSzycho wants to merge 17 commits intomainfrom
Conversation
This is needed as the controller-manager needs the ability to list any type of resource in the cluster
… indexer policies and update deployment restart logic.
scotwells
left a comment
There was a problem hiding this comment.
Getting some early feedback in! Will try and take a look at the Resource embed thing shortly.
| } | ||
| } | ||
| if !found { | ||
| return nil, apierrors.NewBadRequest(fmt.Sprintf("target resource %s/%s %s is not currently indexed or policy is not ready", tr.Group, tr.Version, tr.Kind)) |
There was a problem hiding this comment.
We should use structured errors with field errors so that all errors are returned to the client instead of only validating part of the error.
| &SearchQuery{}, | ||
| &SearchQueryList{}, |
There was a problem hiding this comment.
Let's use the name ResourceSearchQuery so it's a little more unique to what we're searching. This gives us flexibility to have other types of search queries in the future that won't conflict with this type.
| // Resource contains the actual Kubernetes resource. | ||
| Resource runtime.RawExtension `json:"resource"` |
There was a problem hiding this comment.
We'll want to investigate if there's a better way to embed a resource here. I believe this would result in a raw JSON object which is not ideal.
There was a problem hiding this comment.
After investigation, unstructured.Unstructured is the better choice here over runtime.RawExtension.
Why Unstructured:
- Provides typed accessor methods for Go clients (
GetName(),GetNamespace(),GetLabels(), etc.) without requiring manual JSON parsing - Implements
runtime.Object, so it works directly with dynamic clients and controller-runtime machinery - Wire format is identical to
RawExtension—non-Go clients see the same JSON, so this is backward compatible
Why not RawExtension:
- Clients must manually unmarshal and type-assert fields
- No benefit over
Unstructuredsince we are not doing raw byte pass-through
Alternative considered:
We could extract common fields (apiVersion, kind, name, namespace) into explicit struct fields for maximum ergonomics, but Unstructured provides a good balance without duplicating data in the response.
type SearchResult struct {
Resource unstructured.Unstructured `json:"resource"`
RelevanceScore float64 `json:"relevanceScore,omitempty"`
}…nager configuration.
|
|
…ing and dependencies.
…ResourceIndexPolicy protected resource.
…ler-manager and resource-indexer deployments. This is made in order to use the env var pattern to patch the layer easily.
… resource indexer deployment.
…ch Helm chart to v0.26.0
Pull Request: Introduce SearchQuery API and Refine Indexing Infrastructure
Description
This PR introduces the
SearchQueryAPI, enabling full-text search capabilities against Meilisearch through the Kubernetes aggregated API server. It also includes several refinements to the indexing infrastructure, RBAC, and logging.Key Features
1. SearchQuery API Implementation
SearchQueryvirtual resource inpkg/apis/search/v1alpha1.SearchQueryininternal/registry/searchquery/rest.go, handling:MultiSearchAPI.continuetokens that validate against the original search parameters.searchqueriesendpoint.Fixes
1. Indexer and Cache Refinements
PolicyCacheto use a centralized startup and synchronization mechanism based oncontroller-runtime.2. Infrastructure and Tools
Note
Commit 52f2517 contains the actual new feature