Skip to content

Upgrade agent sandbox v0.5.3 - #446

Closed
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:upgrade-agent-sandbox-v0.5.3
Closed

safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:upgrade-agent-sandbox-v0.5.3

Conversation

@safiya2610

@safiya2610 safiya2610 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR upgrades the sigs.k8s.io/agent-sandbox dependency from v0.4.6 to the latest stable release v0.5.3.

As part of this upgrade, all internal workload manager logic and tests have been migrated to use the newly introduced agents.x-k8s.io/v1beta1 and extensions.agents.x-k8s.io/v1beta1 APIs, replacing the older v1alpha1 types.

Key Changes

  • Dependency Update: Bumped sigs.k8s.io/agent-sandbox to v0.5.3 in go.mod and go.sum.
  • v1beta1 Migration:
    • Updated all Sandbox, SandboxClaim, SandboxWarmPool, and SandboxTemplate usages in pkg/workloadmanager to v1beta1.
    • Updated SandboxClaim construction to use WarmPoolRef instead of the deprecated TemplateRef.
  • Immutability Contract: Added TestSandboxVolumeClaimTemplatesImmutability to explicitly enforce and test the new immutability behavior of Sandbox.spec.volumeClaimTemplates.
  • Unit & E2E Tests: Migrated test/e2e/e2e_test.go and all internal pkg/workloadmanager tests to construct and validate v1beta1 objects. Fixed namespace validation defaulting logic in the HTTP creation handler.
  • E2E Scripts: Configured run_e2e.sh to fetch the v0.5.3 sandbox-with-extensions.yaml manifest.

Fixes #438

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes 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

@codecov-commenter

codecov-commenter commented Jul 28, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 66.33663% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.08%. Comparing base (5903457) to head (163ac42).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
pkg/workloadmanager/codeinterpreter_controller.go 40.62% 19 Missing ⚠️
pkg/workloadmanager/k8s_client.go 26.66% 11 Missing ⚠️
pkg/workloadmanager/handlers.go 86.95% 3 Missing ⚠️
pkg/workloadmanager/sandbox_controller.go 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   59.98%   60.08%   +0.09%     
==========================================
  Files          36       35       -1     
  Lines        3589     3650      +61     
==========================================
+ Hits         2153     2193      +40     
- Misses       1216     1236      +20     
- Partials      220      221       +1     
Flag Coverage Δ
unittests 60.08% <66.33%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch from 8294a36 to 822dc7b Compare July 29, 2026 00:40
@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch 3 times, most recently from 9928ed7 to 83002f1 Compare July 29, 2026 12:11
@ranxi2001

Copy link
Copy Markdown
Contributor

#448 has merged into main. Please rebase this PR onto the latest main and drop the overlapping SSE workaround from 83002f1; the merged SDK v2 migration keeps the MCP integration on Streamable HTTP and should resolve the current overlap.

/retest

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

@ranxi2001: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

#448 has merged into main. Please rebase this PR onto the latest main and drop the overlapping SSE workaround from 83002f1; the merged SDK v2 migration keeps the MCP integration on Streamable HTTP and should resolve the current overlap.

/retest

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/test-infra repository.

@safiya2610

Copy link
Copy Markdown
Contributor Author

#448 has merged into main. Please rebase this PR onto the latest main and drop the overlapping SSE workaround from 83002f1; the merged SDK v2 migration keeps the MCP integration on Streamable HTTP and should resolve the current overlap.

/retest

doing it..

@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch 4 times, most recently from 36a4332 to dea727d Compare July 30, 2026 07:09
@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch from dea727d to d769fc5 Compare July 30, 2026 07:12
@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch 2 times, most recently from ebc7670 to 38380c8 Compare July 30, 2026 07:23
@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch 2 times, most recently from aedd7bb to 2eefda6 Compare July 30, 2026 07:53
Comment thread docs/agentcube/docs/getting-started.md Outdated
Comment on lines +39 to +78
### Upgrade Guide (v0.4.6 to v0.5.3)

When upgrading an existing `v0.4.6` installation with active or cold-start `CodeInterpreter` claims (`warmPoolSize > 0`), applying `v0.5.3` directly can cause claims to map to `warmPoolRef.name=shadow-pool-<template>`. Because `v0.5.3` requeues with `WarmPoolNotFound` if the shadow pool does not exist, claims may hit AgentCube's 2-minute create timeout and enter rollback.

To safely upgrade from `v0.4.6` to `v0.5.3`, follow these mandatory steps:

1. **Backup Existing Resources**
```bash
kubectl get sandboxclaims,sandboxes,sandboxtemplates,sandboxwarmpools,codeinterpreters -A -o yaml > backup.yaml
```
2. **Download the Migration Helper**
Obtain the pinned `v0.5.3` migration helper script from the release assets:
```bash
wget https://raw.githubusercontent.com/kubernetes-sigs/agent-sandbox/refs/tags/v0.5.3/helm/files/migrate.sh -O migrate.sh
chmod +x migrate.sh
```
3. **Run Pre-Upgrade Bootstrap**
This prevents `WarmPoolNotFound` errors for existing cold-start claims:
```bash
./migrate.sh --phase=bootstrap
```
4. **Apply v0.5.3 Manifest**
```bash
kubectl apply --server-side -f https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v0.5.3/sandbox-with-extensions.yaml
```
5. **Wait for Readiness**
Wait for the new controller and conversion webhook to be fully responsive before proceeding:
```bash
kubectl rollout status deployment/agent-sandbox-controller -n agent-sandbox-system
for i in {1..30}; do
if kubectl get sandboxwarmpools.extensions.agents.x-k8s.io --all-namespaces >/dev/null 2>&1; then break; fi
if [ $i -eq 30 ]; then echo "Timed out waiting for webhook"; exit 1; fi
sleep 2
done
```
6. **Run Post-Upgrade Migrate**
Execute the migration phase to finalize the upgrade:
```bash
./migrate.sh --phase=migrate
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't need an upgrade guide for Getting started doc.

Comment thread docs/getting-started.md Outdated
> - However, `workloadRef` fields are tombstoned by the Kubernetes v0.36 API schema and will **not** be copied to newly spawned Sandboxes. Legacy `workloadRef` batch-scheduling intent is **unsupported** on v0.36+.
> - Workloads requiring batch-scheduling or pod-group semantics must be updated to use `schedulingGroup` with `podGroupName: <group-name>`.

### Upgrade Guide (v0.4.6 to v0.5.3)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ditto

Comment thread hack/update-codegen.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you explain why you need to touch this file?

[tool.setuptools.packages.find]
where = ["."]
include = ["agentcube_code_interpreter_mcp*"]
include = ["agentcube_code_interpreter_mcp*"] No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't see a need to touch this file.

Comment thread hack/update-codegen.sh Outdated
# Find code-generator
CODEGEN_PKG=""
CODEGEN_VERSION="v0.35.4"
CODEGEN_VERSION="v0.36.2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only this line is needed, I guess.

Comment thread pkg/picod/files_test.go

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Again, I don't know why this is needed.

Comment thread go.mod Outdated
Comment on lines +18 to +20
k8s.io/api v0.36.2
k8s.io/apimachinery v0.36.2
k8s.io/client-go v0.36.2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since agent-sandbox v0.5.3 requires k8s.io/* v0.36.2 and controller-runtime v0.24.1. Could you please spit this into two:

  1. bump k8s + controller-runtime dependencies
  2. then this PR keeps only the agent-sandbox v0.5.3 upgrade

That makes each change easier to review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note: @acsoto has helped to bump the dependencies thing at #465

@RainbowMango

Copy link
Copy Markdown
Collaborator

@safiya2610 Could you please rebase this PR and address the comments?

@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch from 624c875 to 415c1e1 Compare September 28, 2026 04:25
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch from 415c1e1 to 1767d75 Compare September 28, 2026 04:53
Signed-off-by: Safiya <147792763+safiya2610@users.noreply.github.com>
@safiya2610
safiya2610 force-pushed the upgrade-agent-sandbox-v0.5.3 branch from 1767d75 to 163ac42 Compare September 29, 2026 08:36
@safiya2610

safiya2610 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@acsoto @ranxi2001 Please check it once.

@safiya2610

Copy link
Copy Markdown
Contributor Author

@RainbowMango @acsoto @ranxi2001 Please view it once.

}

// Create scheme and register agent-sandbox types
// Create scheme and register agent-sandbox types (both v1alpha1 and v1beta1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This scheme has no consumers; the extra registrations and unused alpha GVRs do not provide migration compatibility.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed. Since this Scheme has no consumers, perhaps we could remove it to avoid confusion.

Also, this upgrade requires some preparation for existing installations. Could we add some upgrade guidance for users?

func getSandboxStatus(sandbox *sandboxv1beta1.Sandbox) string {
for _, condition := range sandbox.Status.Conditions {
if condition.Type == string(sandboxv1alpha1.SandboxConditionReady) && condition.Status == metav1.ConditionTrue {
if (condition.Type == string(sandboxv1beta1.SandboxConditionReady) || condition.Type == string(sandboxv1alpha1.SandboxConditionReady)) && condition.Status == metav1.ConditionTrue {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Both constants are "Ready", so the alpha check and import are redundant.

Comment thread docs/getting-started.md
```

> [!IMPORTANT]
> **Kubernetes Dependency Boundary (`workloadRef` vs `schedulingGroup`)**:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Kubernetes upgrade is already in the base; these compatibility notes and tests belong with that dependency change.

Kind: types.SandboxKind,
Ports: agentRuntimeObj.Spec.Ports,
SessionID: sessionID,
OwnerID: ownerID,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moving OwnerID assignment into both builders is unrelated to the API migration; keeping the existing assignment would reduce the scope.

Comment on lines +155 to +158
TypeMeta: metav1.TypeMeta{
APIVersion: "extensions.agents.x-k8s.io/v1beta1",
Kind: "SandboxTemplate",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We usually don't set TypeMeta explicitly here, since the object is already an extensionsv1beta1.SandboxTemplate and its GVK can be inferred from the registered Scheme.

Comment on lines +219 to +222
TypeMeta: metav1.TypeMeta{
APIVersion: "extensions.agents.x-k8s.io/v1beta1",
Kind: "SandboxWarmPool",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

if warmPool.Spec.Replicas != *ci.Spec.WarmPoolSize {
warmPool.Spec.Replicas = *ci.Spec.WarmPoolSize

if !replicasEqual(warmPool.Spec.Replicas, ci.Spec.WarmPoolSize) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if !replicasEqual(warmPool.Spec.Replicas, ci.Spec.WarmPoolSize) {
if !ptr.Equal(warmPool.Spec.Replicas, ci.Spec.WarmPoolSize) {

Could we use the existing ptr.Equal helper here instead of introducing a new function?

Comment on lines +52 to +57
SandboxGVRv1alpha1 = schema.GroupVersionResource{
Group: "agents.x-k8s.io",
Version: "v1alpha1",
Resource: "sandboxes",
}
SandboxClaimGVRv1alpha1 = schema.GroupVersionResource{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These two GVRs aren’t used anywhere. Could we remove them?

Comment on lines +395 to +398
TypeMeta: metav1.TypeMeta{
APIVersion: "agents.x-k8s.io/v1beta1",
Kind: types.SandboxKind,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need to set TypeMeta here. When a CodeInterpreter uses a warm pool, simpleSandbox is only a placeholder; the SandboxClaim, not this Sandbox, is sent to the dynamic client for creation.

@zhzhuang-zju

Copy link
Copy Markdown
Contributor

Gentle ping @safiya2610

@zhzhuang-zju

Copy link
Copy Markdown
Contributor

Hi @safiya2610, I’d be happy to help finish this PR and address the remaining review comments. Would you be open to me continuing the work?

@zhzhuang-zju

Copy link
Copy Markdown
Contributor

Hi @safiya2610, we’ve decided to upgrade directly to agent-sandbox v1.0.9 in #507, so we can close this PR. Thank you for your work on it!

/close

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

@zhzhuang-zju: You can't close an active issue/PR unless you authored it or you are a collaborator.

Details

In response to this:

Hi @safiya2610, we’ve decided to upgrade directly to agent-sandbox v1.0.9 in #507, so we can close this PR. Thank you for your work on it!

/close

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/test-infra repository.

@acsoto

acsoto commented Nov 9, 2026

Copy link
Copy Markdown
Member

/close

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

@acsoto: Closed this PR.

Details

In response to this:

/close

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/test-infra repository.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade agent-sandbox to v0.5.2 or a later stable release

7 participants