Skip to content

fix(sandbox-kubernetes): keep claim alive across calls so resume works - #4252

Open
iluv7 wants to merge 1 commit into
agentscope-ai:mainfrom
iluv7:fix/k8s-claim-resume
Open

iluv7 wants to merge 1 commit into
agentscope-ai:mainfrom
iluv7:fix/k8s-claim-resume

Conversation

@iluv7

@iluv7 iluv7 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Fixes #4251.

KubernetesSandbox.shutdown() deleted the SandboxClaim on every release, and the harness persisted the claim name afterwards. The next resume() therefore always looked up a claim that no longer existed. K8sHelper.resolveSandboxName() did not treat a null GET as not-found; it started a watch for an absent object and waited the full 30-second resolution timeout before falling back to a fresh create. Warm resume never worked and every call after the first paid the 30-second stall.

Changes:

  • KubernetesSandbox.shutdown() now only closes the client connection. The claim is the identity pointer the persisted state resumes from, so it must outlive one call.
  • K8sHelper.resolveSandboxName() throws SandboxNotFoundException immediately when the initial claim GET returns null, instead of watching an absent object.
  • Claim reclamation stays with the existing shutdownAfterSeconds(...) lifecycle or an explicit terminate() on the SDK handle; no new option or destruction path is introduced.
  • Regression tests: shutdown() does not call terminate(), and a missing claim fails without waiting for a watch.

No .md/documentation files are changed.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test) — K8s module: 73 passed with KubernetesSerializationCompatTest excluded because it needs a local ~/.kube/config; the remaining failure is environmental, not caused by this change
  • Javadoc comments are complete and follow project conventions — no public API/Javadoc changes
  • Related documentation has been updated (e.g. links, examples, etc.) — not needed: this restores the behavior already described in docs/dev/en/docs/harness/sandbox.md
  • Code is ready for review

KubernetesSandbox.shutdown() deleted the SandboxClaim on every release
and the state was persisted afterwards, so the next resume always looked
up a claim that no longer existed. K8sHelper.resolveSandboxName() then
watched an absent object until the 30s resolution timeout before falling
back to a fresh create, which made warm resume unreachable and added a
30s stall to every call after the first.

Keep the claim alive across calls (it is the identity pointer the
persisted state resumes from) and only close the client connection on
release. Reclamation stays with the configured shutdownAfterSeconds
lifecycle or an explicit terminate() on the SDK handle.

Fail fast when the initial claim GET returns null instead of starting a
watch that can never see an event.

This branch has not been deployed

No deployments
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.

[Bug]: Kubernetes sandbox deletes its SandboxClaim on every call, breaking resume and adding a 30s stall

1 participant