-
Notifications
You must be signed in to change notification settings - Fork 207
Replace custom EnvVar with corev1.EnvVar #4570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5cc6965
cfac2af
345f1ca
b29cd5e
ca9dc98
7a502e8
c1388bc
6b4cd67
8dcfd7b
82fd867
0486ace
d37b279
b42ab61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,7 +236,7 @@ type MCPServerSpec struct { | |
| // +listType=map | ||
| // +listMapKey=name | ||
| // +optional | ||
| Env []EnvVar `json:"env,omitempty"` | ||
| Env []corev1.EnvVar `json:"env,omitempty"` | ||
|
|
||
| // Volumes are volumes to mount in the MCP server container | ||
| // +listType=map | ||
|
|
@@ -408,7 +408,7 @@ type ProxyDeploymentOverrides struct { | |
| // +listType=map | ||
| // +listMapKey=name | ||
| // +optional | ||
| Env []EnvVar `json:"env,omitempty"` | ||
| Env []corev1.EnvVar `json:"env,omitempty"` | ||
|
|
||
| // ImagePullSecrets allows specifying image pull secrets for the proxy runner | ||
| // These are applied to both the Deployment and the ServiceAccount | ||
|
|
@@ -429,15 +429,15 @@ type ResourceMetadataOverrides struct { | |
| } | ||
|
|
||
| // EnvVar represents an environment variable in a container | ||
| type EnvVar struct { | ||
| // Name of the environment variable | ||
| // +kubebuilder:validation:Required | ||
| Name string `json:"name"` | ||
|
|
||
| // Value of the environment variable | ||
| // +kubebuilder:validation:Required | ||
| Value string `json:"value"` | ||
| } | ||
| // type EnvVar struct { | ||
| // // Name of the environment variable | ||
| // // +kubebuilder:validation:Required | ||
| // Name string `json:"name"` | ||
|
|
||
| // // Value of the environment variable | ||
| // // +kubebuilder:validation:Required | ||
| // Value string `json:"value"` | ||
| // } | ||
|
Comment on lines
431
to
+440
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MEDIUM] F4: Custom EnvVar type commented out, not deleted (Consensus: 9/10) Dead commented-out code should be deleted entirely. Git history preserves the original type definition if it's ever needed for reference. The Delete this entire block (lines 431-440). Raised by: kubernetes-expert, code-reviewer, toolhive-expert |
||
|
|
||
| // Volume represents a volume to mount in a container | ||
| type Volume struct { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1149,12 +1149,7 @@ func (r *MCPServerReconciler) deploymentForMCPServer( | |
|
|
||
| // Add user-specified proxy environment variables from ResourceOverrides | ||
| if m.Spec.ResourceOverrides != nil && m.Spec.ResourceOverrides.ProxyDeployment != nil { | ||
| for _, envVar := range m.Spec.ResourceOverrides.ProxyDeployment.Env { | ||
| env = append(env, corev1.EnvVar{ | ||
| Name: envVar.Name, | ||
| Value: envVar.Value, | ||
| }) | ||
| } | ||
| env = append(env, m.Spec.ResourceOverrides.ProxyDeployment.Env...) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MEDIUM] F6: Direct pass-through now includes FieldRef/ResourceFieldRef (Consensus: 7/10) Nice simplification, but the full Raised by: go-security-reviewer |
||
| } | ||
|
|
||
| // Add volume mounts for user-defined volumes | ||
|
|
@@ -1762,12 +1757,7 @@ func (r *MCPServerReconciler) deploymentNeedsUpdate( | |
|
|
||
| // Add user-specified environment variables | ||
| if mcpServer.Spec.ResourceOverrides != nil && mcpServer.Spec.ResourceOverrides.ProxyDeployment != nil { | ||
| for _, envVar := range mcpServer.Spec.ResourceOverrides.ProxyDeployment.Env { | ||
| expectedProxyEnv = append(expectedProxyEnv, corev1.EnvVar{ | ||
| Name: envVar.Name, | ||
| Value: envVar.Value, | ||
| }) | ||
| } | ||
| expectedProxyEnv = append(expectedProxyEnv, mcpServer.Spec.ResourceOverrides.ProxyDeployment.Env...) | ||
| } | ||
| // Add default environment variables that are always injected | ||
| expectedProxyEnv = ctrlutil.EnsureRequiredEnvVars(ctx, expectedProxyEnv) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -566,7 +566,7 @@ func (*MCPServerReconciler) validateToolsFilter(config *runner.RunConfig) error | |
| } | ||
|
|
||
| // convertEnvVarsFromMCPServer converts MCPServer environment variables to builder format | ||
| func convertEnvVarsFromMCPServer(envs []mcpv1alpha1.EnvVar) map[string]string { | ||
| func convertEnvVarsFromMCPServer(envs []corev1.EnvVar) map[string]string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blocker: The issue (#4547) notes that controller conversion logic should be simplified now that the types match directly. This function converts to Those two locations should be simplified to: env = append(env, m.Spec.ResourceOverrides.ProxyDeployment.Env...)Without this,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good Catch ! Totally missed these
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] F2: This function now accepts Add validation that detects and rejects Raised by: kubernetes-expert, code-reviewer, toolhive-expert, go-security-reviewer |
||
| if len(envs) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] F3: EmbeddingServer controller
buildEnvVarsalso dropsValueFrom(Consensus: 9/10)The
EmbeddingServerReconciler.buildEnvVarsfunction atembeddingserver_controller.go:640-644manually copies onlyName/Valueinto newcorev1.EnvVarstructs, discardingValueFrom. Since this function already returns[]corev1.EnvVar, the fix is straightforward: replace the conversion loop withenvVars = append(envVars, embedding.Spec.Env...)to pass through the full struct, matching the pattern used in the MCPServer proxy deployment code.Raised by: kubernetes-expert, code-reviewer