Skip to content

feat: implement multi-tenant search support#72

Merged
JoseSzycho merged 11 commits intomainfrom
70-implement-multi-tenant-search-support
Mar 26, 2026
Merged

feat: implement multi-tenant search support#72
JoseSzycho merged 11 commits intomainfrom
70-implement-multi-tenant-search-support

Conversation

@JoseSzycho
Copy link
Copy Markdown
Contributor

feat: implement multi-tenant search support

Summary

The search service previously indexed only platform cluster resources, with no awareness of project control planes. This adds multi-tenant support so resources from any Milo project can be discovered and searched alongside platform resources, with full tenant attribution on every result.

When --multi-tenant=true, the controller-manager watches resourcemanager.miloapis.com/v1alpha1/projects and maintains a per-project dynamic client (proxied through the platform API server — no separate credentials needed). On policy reconcile, it publishes reindex messages for platform resources and each active project's resources. When a project is deleted, its documents are removed from Meilisearch via DeleteDocumentsByFilter. The audit event consumer extracts tenant identity from user.extra IAM fields and skips non-platform events in single-tenant mode to prevent misclassification.

Key behaviours:

  • --multi-tenant defaults to false — single-tenant deployments are completely unaffected
  • Every indexed document carries _tenant and _tenant_type as filterable attributes; SearchResult exposes a TenantInfo object with name and type
  • In single-tenant mode, audit events for non-platform tenants are acked and dropped rather than indexed under the wrong tenant
  • --project-label-selector allows scoping which projects are indexed without code changes

Copy link
Copy Markdown
Contributor

@scotwells scotwells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just some feedback around failure scenarios to make sure we retry appropriately.

Comment on lines +343 to +345
// The baseline filterable attributes ensure that _tenant and _tenant_type are always
// present so multi-tenant filter queries work regardless of policy field configuration.
baseFilterableAttributes := []string{"uid", "metadata.name", "metadata.namespace", "_tenant", "_tenant_type"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on automatically indexing metadata.annotations["kubernetes.io/display-name"] and metadata.annotations["kubernetes.io/description"] since we're standardizing on those for human-readable display names and descriptions? Maybe this is also worth moving into a configuration file so we can dynamically change it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, but our ResourceIndexPolicySpec already allows to configure with annotations we want to index.

We can already use the ResourceIndex to configure that, and is functionality that is already in place, and working

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm confused on what baseFilterableAttributes is being used for. Based on the name, I assumed these were fields within the resource that would always be indexed, regardless of the policy configuration.

@JoseSzycho
Copy link
Copy Markdown
Contributor Author

@scotwells I left to conversations open (not resolved). Will be waiting for your reply in order to continue.

@JoseSzycho JoseSzycho requested a review from scotwells March 26, 2026 13:27
scotwells
scotwells previously approved these changes Mar 26, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Ready in Searching Resources in Milo Mar 26, 2026
@JoseSzycho JoseSzycho merged commit 8a6ccc2 into main Mar 26, 2026
7 checks passed
@JoseSzycho JoseSzycho deleted the 70-implement-multi-tenant-search-support branch March 26, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement Multi-Tenant Search Support

2 participants