Summary
MCPServerReconciler.deploymentNeedsUpdate does not mirror the Redis password env var that deploymentForMCPServer adds. When sessionStorage.provider == "redis" and a passwordRef is set, the actual proxy Deployment carries the THV_SESSION_REDIS_PASSWORD entry but the expected env slice built by deploymentNeedsUpdate does not — equality.Semantic.DeepEqual then flags drift and the controller rewrites the Deployment on every reconcile.
Where
- Construction site:
cmd/thv-operator/controllers/mcpserver_controller.go:1153 — env = append(env, r.buildRedisPasswordEnvVar(m)...)
- Drift comparison:
MCPServerReconciler.deploymentNeedsUpdate rebuilds expectedProxyEnv (around line 1710 onwards) but never calls buildRedisPasswordEnvVar.
The only call site for buildRedisPasswordEnvVar is the construction path. Confirmed by:
$ grep -n 'buildRedisPasswordEnvVar' cmd/thv-operator/controllers/mcpserver_controller.go
1153: env = append(env, r.buildRedisPasswordEnvVar(m)...)
2489:// buildRedisPasswordEnvVar returns the THV_SESSION_REDIS_PASSWORD env var when
2491:func (*MCPServerReconciler) buildRedisPasswordEnvVar(m *mcpv1beta1.MCPServer) []corev1.EnvVar {
Impact
Suggested fix
Mirror buildRedisPasswordEnvVar in deploymentNeedsUpdate at the same relative position it occupies in deploymentForMCPServer (after user-override env vars, before the new THV_MCPSERVER_GENERATION downward-API entry from #5364).
// In deploymentNeedsUpdate, before the THV_MCPSERVER_GENERATION block:
expectedProxyEnv = append(expectedProxyEnv, r.buildRedisPasswordEnvVar(mcpServer)...)
Add a focused unit test asserting deploymentNeedsUpdate returns false after deploymentForMCPServer when an MCPServer has sessionStorage.provider: redis with a passwordRef. There's no such regression test today.
Related
Summary
MCPServerReconciler.deploymentNeedsUpdatedoes not mirror the Redis password env var thatdeploymentForMCPServeradds. WhensessionStorage.provider == "redis"and apasswordRefis set, the actual proxy Deployment carries theTHV_SESSION_REDIS_PASSWORDentry but the expected env slice built bydeploymentNeedsUpdatedoes not —equality.Semantic.DeepEqualthen flags drift and the controller rewrites the Deployment on every reconcile.Where
cmd/thv-operator/controllers/mcpserver_controller.go:1153—env = append(env, r.buildRedisPasswordEnvVar(m)...)MCPServerReconciler.deploymentNeedsUpdaterebuildsexpectedProxyEnv(around line 1710 onwards) but never callsbuildRedisPasswordEnvVar.The only call site for
buildRedisPasswordEnvVaris the construction path. Confirmed by:Impact
resourceVersionincrements on every reconcile.Suggested fix
Mirror
buildRedisPasswordEnvVarindeploymentNeedsUpdateat the same relative position it occupies indeploymentForMCPServer(after user-override env vars, before the newTHV_MCPSERVER_GENERATIONdownward-API entry from #5364).Add a focused unit test asserting
deploymentNeedsUpdatereturnsfalseafterdeploymentForMCPServerwhen an MCPServer hassessionStorage.provider: rediswith apasswordRef. There's no such regression test today.Related