You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extract mutation from Validate method into separate defaulting logic #4628
apiItems related to the APIbugSomething isn't workinggoPull requests that update go codekubernetesItems related to KubernetesoperatorvmcpVirtual MCP Server related issues
The validateEmbeddingServer method on VirtualMCPServer mutates r.Spec.Config.Optimizer during validation — a defaulting operation hidden inside a validation function. The mutation is never persisted to the API server, is re-applied every reconciliation from a fresh cache copy, and is invisible to users via kubectl get.
// EmbeddingServerRef is set but optimizer is not configured: auto-populate// optimizer with default values so the embedding server is actually used.ifhasRef&&!hasOptimizer {
r.Spec.Config.Optimizer=&config.OptimizerConfig{}
}
This mutation inside a Validate() method:
Is never persisted to the API server (the controller doesn't write back to spec)
Is re-applied every reconciliation from a fresh cache copy
Is invisible to users via kubectl get
Impact
Violation of separation of concerns (validation should not mutate)
Users see a different spec than what the controller uses
If webhooks are implemented, this logic would need to be a Defaulter, not a Validator
Recommended Fix
Extract to a separate ApplyDefaults() method or a proper Default() webhook
Call ApplyDefaults() before Validate() in the controller
Document that the defaulting is controller-side only
apiItems related to the APIbugSomething isn't workinggoPull requests that update go codekubernetesItems related to KubernetesoperatorvmcpVirtual MCP Server related issues
Activity