Skip to content

fix(controller/test): use manager's client to access cache with e.g. custom fields#490

Merged
vdice merged 1 commit intospinframework:mainfrom
vdice:fix/setup-executor-controller-test
Mar 30, 2026
Merged

fix(controller/test): use manager's client to access cache with e.g. custom fields#490
vdice merged 1 commit intospinframework:mainfrom
vdice:fix/setup-executor-controller-test

Conversation

@vdice
Copy link
Copy Markdown
Contributor

@vdice vdice commented Mar 30, 2026

Use mgr.GetClient() instead of the direct client to the raw API server, so that custom fields (i.e. fields specific to the Spin-Operator, e.g. 'spec.executor') are valid.

This fix was provoked by a PR in the queue (#481) in which tests were added making API calls with the spec.executor custom field. Without this fix, errors like the following were occurring due to the raw K8s API server rejecting the field:

2026-03-30T10:08:41-06:00	ERROR	Unable to list SpinApps	{"controller": "spinappexecutor", "controllerGroup": "core.spinkube.dev", "controllerKind": "SpinAppExecutor", "SpinAppExecutor": {"name":"containerd-shim-spin","namespace":"test-ns-a"}, "namespace": "test-ns-a", "name": "containerd-shim-spin", "reconcileID": "fed21f07-b128-4f50-b421-4d2e2ed799b3", "error": "field label not supported: spec.executor"}

…custom fields

Signed-off-by: Vaughn Dice <vdice@akamai.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the SpinAppExecutor controller envtest setup so the reconciler uses the controller-runtime manager’s cached client, enabling MatchingFields queries on custom fields like spec.executor during tests (mirroring production behavior).

Changes:

  • Switch SpinAppExecutorReconciler.Client in tests from the direct API client to mgr.GetClient() (cache-backed).
  • Ensures field-indexed lookups (e.g., spec.executor) don’t hit the raw API server field-selector validation path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

LGTM

@vdice vdice merged commit 0718e11 into spinframework:main Mar 30, 2026
22 checks passed
@vdice vdice deleted the fix/setup-executor-controller-test branch March 30, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants