Skip to content

feat: apply K8sSettings resources and enable sync for SystemMCPServer#6038

Open
wklee610 wants to merge 9 commits intoobot-platform:mainfrom
wklee610:main
Open

feat: apply K8sSettings resources and enable sync for SystemMCPServer#6038
wklee610 wants to merge 9 commits intoobot-platform:mainfrom
wklee610:main

Conversation

@wklee610
Copy link
Copy Markdown

Summary

This PR ensures that SystemMCPServer pods respect Kubernetes resource configurations and automatically redeploy when those settings change.

Key Changes

Apply resources to all containers
mcp-shim and other related containers now correctly inherit requests/limits from K8sSettings.Resources.

Track Kubernetes settings changes
Added NeedsK8sUpdate and K8sSettingsHash to SystemMCPServerStatus to detect configuration updates.

Watch SystemMCPServer deployments
Updated deployment handlers to monitor SystemMCPServer (sms*) objects, not just MCPServer.

Automatic redeploy on config change
During reconciliation, if NeedsK8sUpdate is true, the controller gracefully shuts down the existing pod and redeploys it with the updated settings.

Copilot AI review requested due to automatic review settings March 10, 2026 14:41
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

Adds K8s-settings drift handling and resource defaults to improve Kubernetes deployments for MCP servers, including SystemMCPServer.

Changes:

  • Add NeedsK8sUpdate status flag to SystemMCPServerStatus and trigger redeploy logic in the system server controller.
  • Apply K8sSettings.Resources (or defaults) to additional Kubernetes containers during object creation.
  • Extend the deployment-status copier to handle SystemMCPServer objects in addition to MCPServer.

Reviewed changes

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

File Description
pkg/storage/apis/obot.obot.ai/v1/systemmcpserver.go Adds NeedsK8sUpdate to SystemMCPServer status.
pkg/mcp/kubernetes.go Sets container Resources from K8s settings (with defaults) for additional containers.
pkg/controller/handlers/systemmcpserver/systemmcpserver.go Shuts down system server deployments when NeedsK8sUpdate is set to force redeploy.
pkg/controller/handlers/deployment/deployment.go Updates deployment-to-status syncing to support SystemMCPServer and propagate K8s drift status.

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

Comment on lines +170 to +171
systemServer.Status.NeedsK8sUpdate = false
return req.Client.Status().Update(req.Ctx, systemServer)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Clearing NeedsK8sUpdate without also updating Status.K8sSettingsHash to the current expected hash can cause the deployment watcher to immediately set NeedsK8sUpdate back to true while the old Deployment (with the old hash annotation) still exists, leading to repeated shutdown/redeploy cycles. Consider fetching current K8sSettings here, computing the current hash, and updating Status.K8sSettingsHash alongside clearing the flag (similar to the MCPServer redeploy path in pkg/api/handlers/mcp.go).

Suggested change
systemServer.Status.NeedsK8sUpdate = false
return req.Client.Status().Update(req.Ctx, systemServer)
// Leave NeedsK8sUpdate and any associated hash fields unchanged here.
// The component responsible for reconciling the K8s deployment should
// update the hash and clear the flag together once the deployment is in sync.
return nil

Copilot uses AI. Check for mistakes.
Comment on lines +671 to +680
Resources: func() corev1.ResourceRequirements {
if k8sSettings.Resources != nil {
return *k8sSettings.Resources
}
return corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("400Mi"),
},
}
}(),
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Now that resources can be set on this non-"mcp" container at creation time, note that RestartServerDeployment/patchDeploymentWithK8sSettings currently only patches resources for the "mcp" container. That means a restart used to apply new K8sSettings.Resources won’t update resources for this container, and the hash may still be updated after verification. Consider extending the patch + match logic to cover resources for all relevant containers, or ensure redeploy uses delete/recreate when resources drift.

Suggested change
Resources: func() corev1.ResourceRequirements {
if k8sSettings.Resources != nil {
return *k8sSettings.Resources
}
return corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("400Mi"),
},
}
}(),
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("400Mi"),
},
},

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 14:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 3 out of 3 changed files in this pull request and generated 4 comments.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 14:59
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 3 out of 3 changed files in this pull request and generated 2 comments.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 15:05
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 2 out of 2 changed files in this pull request and generated 2 comments.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 15:11
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 2 out of 2 changed files in this pull request and generated 1 comment.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 15:16
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 2 out of 2 changed files in this pull request and generated 1 comment.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 04:31
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 2 out of 2 changed files in this pull request and generated 1 comment.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants