Batch MCPServer status updates to reduce API calls per reconciliation
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Summary
The MCPServer controller calls r.Status().Update() from many independent validation helpers, resulting in 6+ distinct status update API calls on a single happy-path reconcile. This causes unnecessary API server load, conflict errors from consecutive racing updates, and wasted work when later updates overwrite earlier ones.
Severity: MUST FIX
Area: Controller Logic
Breaking: No
Location
cmd/thv-operator/controllers/mcpserver_controller.go
Problem
The controller makes separate r.Status().Update() calls from many independent helpers:
validateGroupRef(line 577)updateCABundleStatus(line 674)validateAndUpdatePodTemplateStatus(lines 737, 756)setImageValidationCondition+ update (lines 267, 279, 293, 304)handleToolConfig(line 952)- Multiple others in status reconciliation paths
35 total call sites exist; 6+ distinct on the happy path. On error paths, even more.
Impact
- API server load: 6-12 status update calls per reconcile instead of 1
- Conflict errors when consecutive updates race
- Wasted work when a later update overwrites an earlier one
Recommended Fix
Adopt the StatusManager/StatusCollector pattern already used by VirtualMCPServer and MCPRegistry:
- Collect all condition/status mutations during reconciliation
- Apply them in a single batch at the end
- Remove independent
Status().Update()calls from validation helpers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cmd/thv-operator/controllers/mcpserver_controller.go and compare the StatusManager/StatusCollector pattern already used by VirtualMCPServer and MCPRegistry. Trace the listed validation and status reconciliation helpers, then verify that their mutations are collected and applied in one batch instead of independent Status().Update() calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- backend, infrastructure
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100