Repository navigation
fix: do not revert HPA-managed replicas of MCPServer deployments - #144
Open
gaarutyunov wants to merge 1 commit into
Open
gaarutyunov wants to merge 1 commit into
gaarutyunov wants to merge 1 commit into
Conversation
The MCPServer CRD defaulted spec.deployment.replicas to 1 and the controller fully replaced the Deployment on every reconcile. Because the controller also watches its Deployments, every scale event from a HorizontalPodAutoscaler triggered a reconcile that reset replicas to 1. Drop the CRD default and keep the live replica count when the MCPServer does not set one, matching how kagent handles Agent deployments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: German Arutyunov <garutyunov@tradingview.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #145
Problem
A HorizontalPodAutoscaler cannot scale the Deployment of an
MCPServer:spec.deployment.replicasto1, so the field is never empty.upsertOutputreplaces the whole Deployment on every reconcile.Owns(&appsv1.Deployment{})), so each HPA scale event triggers a reconcile that resets replicas to 1 right away.Change
+kubebuilder:default=1fromMCPServerDeployment.Replicas, and update both CRD copies (config/crd/basesandhelm/kmcp-crds).upsertOutputkeeps the live count. A new Deployment still starts at 1 through the Kubernetes default.mutateDeploymentin kagent'stranslator/mutate.go).An explicit
replicasstill wins, so existing manifests that set it behave as before.Testing
TestUpsertOutputReplicas, using the controller-runtime fake client. It checks that an unset value keeps the live count of 3, and that an explicit 2 overrides it.make manifests. Please let CI confirm.🤖 Generated with Claude Code