Skip to content

feat(runner): add WithCacheByObject for per-object cache namespace scoping - #301

Open
liangwen12year wants to merge 1 commit into
llm-d:mainfrom
liangwen12year:feat/runner-cache-by-object
Open

feat(runner): add WithCacheByObject for per-object cache namespace scoping#301
liangwen12year wants to merge 1 commit into
llm-d:mainfrom
liangwen12year:feat/runner-cache-by-object

Conversation

@liangwen12year

Copy link
Copy Markdown

Summary

  • Add WithCacheByObject(map[client.Object]cache.ByObject) method to Runner
  • Allows downstream consumers to configure per-object cache namespace scoping on the controller-runtime manager
  • Entries in ByObject override DefaultNamespaces (set via the NAMESPACE env var) for the specified object types

Motivation

Downstream consumers (e.g. opendatahub-io/ai-gateway-payload-processing) need to scope the Secret informer to specific namespaces for RBAC hardening. Without this, the default cache does a cluster-scoped LIST /api/v1/secrets that requires a ClusterRoleBinding with cluster-wide secrets access. With WithCacheByObject, the Secret informer can be scoped to model namespaces, allowing namespace-scoped RoleBindings instead.

Usage

runner.NewRunner().
    WithCacheByObject(map[client.Object]cache.ByObject{
        &corev1.Secret{}: {
            Namespaces: map[string]cache.Config{
                "model-namespace": {},
            },
        },
    }).
    WithCustomControllers(...).
    Run(ctx)

Changes

  • cmd/runner/runner.go: Add cacheByObject field to Runner struct, WithCacheByObject builder method, and wire ByObject into cache.Options in Run()
  • cmd/runner/runner_test.go: Unit tests for the new method

Closes #300

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

🚨 Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@github-actions github-actions Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 26, 2026

@lphiri lphiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM.
This gives users flexibility to limit service account privileges.

@liangwen12year
liangwen12year force-pushed the feat/runner-cache-by-object branch from 0552ff6 to 9d18503 Compare August 31, 2026 13:25
…oping

Add a WithCacheByObject method to Runner that lets downstream consumers
configure cache.Options.ByObject for specific resource types. This
enables per-object namespace scoping — e.g. restricting the Secret
informer to model namespaces — while keeping other informers
cluster-wide.

Without this, consumers that need namespace-scoped RBAC for secrets
(RoleBindings instead of ClusterRoleBindings) cannot use the Runner
because the default cache does a cluster-scoped LIST that requires
cluster-wide access.

Closes llm-d#300

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
@liangwen12year
liangwen12year force-pushed the feat/runner-cache-by-object branch from 9d18503 to f66b1fa Compare August 31, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runner: support per-object cache namespace scoping (ByObject)

2 participants