Skip to content

References printcolumn shows raw JSON instead of useful summary#5267

Merged
ChrisJBurns merged 3 commits into
stacklok:mainfrom
Sanskarzz:printcolumnfix1
May 15, 2026
Merged

References printcolumn shows raw JSON instead of useful summary#5267
ChrisJBurns merged 3 commits into
stacklok:mainfrom
Sanskarzz:printcolumnfix1

Conversation

@Sanskarzz
Copy link
Copy Markdown
Contributor

Summary

  • kubectl get output for MCPExternalAuthConfig, MCPOIDCConfig, and MCPToolConfig rendered References as raw JSON because the printer column pointed at
    .status.referencingWorkloads, which is an array of workload reference objects.
  • Added a status.referenceCount field to those resources and updated the References printer column to show the integer count instead.
  • Updated controllers to keep referenceCount in sync whenever referencingWorkloads changes.
  • Regenerated CRD manifests and Helm CRD templates.

Fixes #4618

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

This adds an optional status field, referenceCount, and keeps the existing referencingWorkloads field unchanged.

Changes

File Change
cmd/thv-operator/api/v1alpha1/types.go Updated affected v1alpha1 print columns to use .status.referenceCount
cmd/thv-operator/api/v1beta1/*config_types.go Added referenceCount status fields and updated print columns
cmd/thv-operator/controllers/* Populated referenceCount alongside referencingWorkloads
cmd/thv-operator/controllers/workload_reference_count.go Added guarded helper for converting workload reference length to int32
deploy/charts/operator-crds/** Regenerated CRD manifests and Helm templates

Does this introduce a user-facing change?

Yes. kubectl get now shows the References column as a count instead of raw JSON for MCPExternalAuthConfig, MCPOIDCConfig, and MCPToolConfig.

Special notes for reviewers

The detailed workload references are still available in .status.referencingWorkloads; this only changes the default table output to use .status.referenceCount.

@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label May 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.40%. Comparing base (17451d1) to head (b52eafd).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../thv-operator/controllers/toolconfig_controller.go 60.00% 1 Missing and 1 partial ⚠️
...v-operator/controllers/mcpoidcconfig_controller.go 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5267      +/-   ##
==========================================
+ Coverage   68.39%   68.40%   +0.01%     
==========================================
  Files         619      620       +1     
  Lines       63318    63354      +36     
==========================================
+ Hits        43305    43340      +35     
+ Misses      16782    16776       -6     
- Partials     3231     3238       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed size/M Medium PR: 300-599 lines changed and removed size/S Small PR: 100-299 lines changed labels May 12, 2026
Comment thread cmd/thv-operator/api/v1alpha1/types.go
Copy link
Copy Markdown
Contributor

@amirejaz amirejaz left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! The overall approach is solid — storing a derived referenceCount integer on the status and pointing the printer column at it is exactly the right fix for the raw-JSON display problem. The code is well-structured, tests are thorough, and the CRD manifests and docs are all regenerated consistently.

I have a couple of observations worth discussing, mostly around the stale-count repair path that was added to the three updateOIDCConfigReferencingWorkloads functions.

Comment thread cmd/thv-operator/controllers/mcpserver_controller.go Outdated
Comment thread cmd/thv-operator/controllers/workload_reference_count.go
Comment thread cmd/thv-operator/controllers/workload_reference_count_test.go
Sanskarzz added 3 commits May 15, 2026 20:32
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels May 15, 2026
@ChrisJBurns ChrisJBurns merged commit 439977d into stacklok:main May 15, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

References printcolumn shows raw JSON instead of useful summary

3 participants