Skip to content

Conversation

@vicentefb
Copy link
Contributor

@vicentefb vicentefb commented Oct 28, 2025

Fixes #108

This PR introduces shutdownTime feature to the sandbox extensions, allowing users to define an expiration time for their sandboxes. This feature is implemented with an override pattern:

  1. A default shutdownTime can be set in the SandboxTemplate.
  2. A user can optionally provide a shutdownTime in their SandboxClaim to override the template's default.

This logic is implemented in the sandboxclaim-controller, which copies the correct (overridden or default) shutdownTime to the Sandbox resource upon creation. The core sandbox-controller is then responsible for watching this field and deleting the sandbox pod when the time is reached.

@netlify
Copy link

netlify bot commented Oct 28, 2025

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 01f8f1d
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/690ccdc77cd690000857da82

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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 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. labels Oct 28, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @vicentefb. Thanks for your PR.

I'm waiting for a github.com 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.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 28, 2025
@vicentefb vicentefb force-pushed the AddShutdownTimeToSandboxTemplate branch 2 times, most recently from 055781e to d8d27ee Compare October 28, 2025 02:52
@syangx39
Copy link

  1. Do we have logic to prevent users from creating a Sandbox with shutdownTime in the past?
  2. Also no action needed but please be aware we might have an up-to 2s deletion lag.

@vicentefb
Copy link
Contributor Author

Do we have logic to prevent users from creating a Sandbox with shutdownTime in the past?

Thanks! Yes, there's this if statement in the sandbox controller that checks if the current time is after the shutdownTime https://github.com/kubernetes-sigs/agent-sandbox/blob/main/controllers/sandbox_controller.go#L448-L451

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 31, 2025
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2025
@vicentefb vicentefb force-pushed the AddShutdownTimeToSandboxTemplate branch from 71123b0 to 01f8f1d Compare November 6, 2025 16:33
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2025
@janetkuo
Copy link
Member

janetkuo commented Nov 7, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 7, 2025
// template should be deleted.
// +kubebuilder:validation:Format="date-time"
// +optional
ShutdownTime *metav1.Time `json:"shutdownTime,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I believe shutdownTime is better placed in the SandboxClaim rather than the template. This would give users more direct control over the lifecycle of each sandbox. Let me know if you have other use cases in mind.

"time" // Added for shutdownTime

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp" // Added for ignoring fields
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need comments for imports

"sigs.k8s.io/controller-runtime/pkg/reconcile"

"sigs.k8s.io/agent-sandbox/api/v1alpha1"
sandboxv1alpha1 "sigs.k8s.io/agent-sandbox/api/v1alpha1"
Copy link
Member

Choose a reason for hiding this comment

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

This seems repetitive, just keep the sandboxv1alpha1 one

},
Spec: extensionsv1alpha1.SandboxTemplateSpec{
PodTemplate: sandboxv1alpha1.PodTemplate{
PodTemplate: v1alpha1.PodTemplate{
Copy link
Member

Choose a reason for hiding this comment

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

This change doesn't seem needed

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add shutdownTime field to sandbox CRs in extensions

5 participants