Skip to content

feat: in-place resize of workspace resources on running sandboxes#487

Closed
noeljackson wants to merge 3 commits intokubernetes-sigs:mainfrom
noeljackson:pr/in-place-resize
Closed

feat: in-place resize of workspace resources on running sandboxes#487
noeljackson wants to merge 3 commits intokubernetes-sigs:mainfrom
noeljackson:pr/in-place-resize

Conversation

@noeljackson
Copy link
Copy Markdown
Contributor

Summary

  • When SandboxClaim.spec.workspaceResources is updated on a claim with an existing running sandbox, the controller now patches the pod's container resources in-place
  • On Kubernetes 1.27+ with InPlacePodVerticalScaling, this triggers the kubelet to call UpdateContainerResources on the container runtime, resizing the workload without restart
  • Previously the controller logged "sandbox already exists, skipping update" and ignored resource changes on existing claims

Why

Today updating workspaceResources on a live SandboxClaim has no effect. Users must delete and recreate the claim to change resource allocation, which restarts the workload and loses in-memory state.

Kubernetes 1.27 introduced InPlacePodVerticalScaling (GA in 1.33) which allows patching pod resources without restart. This change makes the SandboxClaim controller use that path so resource changes take effect immediately on running sandboxes.

Changes

  • reconcileWorkspaceResources() added to the existing-sandbox reconcile path. Compares the claim's workspaceResources with the pod's current container resources and patches them if they differ
  • buildResizePatch() helper builds the resource diff. Only CPU and memory are compared. DiskGB (ephemeral storage) is excluded because it cannot be resized in-place
  • The pod patch uses a strategic merge patch, which the API server routes through the resize admission path

Depends on

Test plan

  • Existing unit tests pass
  • Create SandboxClaim with workspaceResources, wait for pod running
  • Patch claim with new memoryMB/cpuMillicores values
  • Verify pod resources updated without pod restart
  • Verify no-op when patching with same values

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: noeljackson
Once this PR has been reviewed and has the lgtm label, please assign soltysh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 29, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @noeljackson. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 29, 2026

Deploy Preview for agent-sandbox ready!

Name Link
🔨 Latest commit b6fb6a9
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69c8f53181bdb00008eb7b9d
😎 Deploy Preview https://deploy-preview-487--agent-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 29, 2026
When SandboxClaim.spec.workspaceResources is updated on a claim with an
existing running sandbox, the controller now patches the pod's container
resources in-place. On Kubernetes 1.27+ with InPlacePodVerticalScaling,
this triggers the kubelet to call UpdateContainerResources on the
container runtime, resizing the workload without restart.

Previously, resource changes on existing claims were silently ignored
('sandbox already exists, skipping update').
@noeljackson
Copy link
Copy Markdown
Contributor Author

Folded into #459. The in-place resize logic is now part of the workspace-resources PR so the feature is complete in one PR (creation, warm pool adoption, and runtime resource updates all work).

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants