Skip to content

Wire spec-driven replicas and session storage validation for MCPServer#4364

Merged
yrobla merged 2 commits intomainfrom
issue-4217
Mar 26, 2026
Merged

Wire spec-driven replicas and session storage validation for MCPServer#4364
yrobla merged 2 commits intomainfrom
issue-4217

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Mar 25, 2026

Summary

  • resolveDeploymentReplicas: nil-passthrough preserves HPA compatibility, stdio cap enforced at 1 as defense-in-depth
  • Add terminationGracePeriodSeconds (30s default) to proxy runner pod spec
  • validateStdioReplicaCap: Warning condition when stdio + spec.replicas > 1
  • validateSessionStorageForReplicas: Warning condition when replicas > 1 without Redis session storage configured

Fixes #4217

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)

Changes

File Change

Does this introduce a user-facing change?

Special notes for reviewers

@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 25, 2026
@yrobla yrobla requested a review from Copilot March 25, 2026 12:01
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b3a4aa972

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 84.37500% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.48%. Comparing base (9c8f5ec) to head (5446ffc).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...d/thv-operator/controllers/mcpserver_controller.go 84.37% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4364      +/-   ##
==========================================
- Coverage   69.50%   69.48%   -0.02%     
==========================================
  Files         482      485       +3     
  Lines       49223    49493     +270     
==========================================
+ Hits        34213    34391     +178     
- Misses      12365    12438      +73     
- Partials     2645     2664      +19     

☔ 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.

Copy link
Copy Markdown
Contributor

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

This PR wires MCPServer replica handling to be spec-driven while preserving external autoscaling compatibility (nil-passthrough), adds a default pod termination grace period, and introduces status-condition validations for unsupported/unsafe scaling configurations.

Changes:

  • Set Deployment.Spec.Replicas from spec.replicas with nil-passthrough; enforce stdio replica cap (defense-in-depth) via resolveDeploymentReplicas.
  • Add TerminationGracePeriodSeconds (default 30s) to the proxy runner pod spec.
  • Add reconciler validations that emit status conditions for (a) stdio + replicas > 1 and (b) replicas > 1 without Redis session storage; expand unit tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
cmd/thv-operator/controllers/mcpserver_controller.go Implements spec-driven replicas, termination grace period default, and new status-condition validations.
cmd/thv-operator/api/v1alpha1/mcpserver_types.go Adds new MCPServer condition type/reason constants for stdio replica capping and session storage warnings.
cmd/thv-operator/controllers/mcpserver_replicas_test.go Updates default replica expectation to nil and adds unit tests for replica resolution, termination grace period, and conditions.
cmd/thv-operator/controllers/mcpserver_pod_template_test.go Removes now-redundant int64Ptr helper (provided by controller package).

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

@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 Mar 25, 2026
@yrobla yrobla requested a review from Copilot March 25, 2026 12:15
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


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

@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 Mar 25, 2026
jerm-dro
jerm-dro previously approved these changes Mar 25, 2026
@yrobla yrobla force-pushed the feat/thv-0047-crd-type-changes branch 3 times, most recently from 31e22a5 to 6788d84 Compare March 26, 2026 10:12
Base automatically changed from feat/thv-0047-crd-type-changes to main March 26, 2026 10:26
@yrobla yrobla dismissed jerm-dro’s stale review March 26, 2026 10:26

The base branch was changed.

taskbot added 2 commits March 26, 2026 11:31
Add SessionStorageConfig struct and scaling fields to MCPServer and
VirtualMCPServer CRDs as the foundation for horizontal scaling support.

- Add SessionStorageConfig struct with Provider, Address, DB, KeyPrefix,
  and PasswordRef fields; CEL rule enforces address is required for redis
- Add Replicas *int32, BackendReplicas *int32, SessionStorage to MCPServerSpec
- Add Replicas *int32, SessionStorage to VirtualMCPServerSpec
- Nil pointer fields allow HPA to manage replicas without operator interference
- Regenerate zz_generated.deepcopy.go and CRD manifests

Closes: #4206
- resolveDeploymentReplicas: nil-passthrough preserves HPA compatibility,
  stdio cap enforced at 1 as defense-in-depth
- Add terminationGracePeriodSeconds (30s default) to proxy runner pod spec
- validateStdioReplicaCap: Warning condition when stdio + spec.replicas > 1
- validateSessionStorageForReplicas: Warning condition when replicas > 1
  without Redis session storage configured

Closes #4217
@github-actions github-actions bot removed the size/M Medium PR: 300-599 lines changed label Mar 26, 2026
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 26, 2026
@yrobla yrobla merged commit 6b8f044 into main Mar 26, 2026
40 checks passed
@yrobla yrobla deleted the issue-4217 branch March 26, 2026 10:57
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.

Extend MCPServer reconciler and deployment builder with spec-driven replicas, stdio cap, session storage validation, and terminationGracePeriodSeconds

5 participants