Skip to content

Cleanup PSS SDK client and enable filtering snapshots by creationTimestamp#732

Merged
k8s-ci-robot merged 10 commits into
kubernetes-sigs:mainfrom
shrutiyam-glitch:update-pss-client
May 26, 2026
Merged

Cleanup PSS SDK client and enable filtering snapshots by creationTimestamp#732
k8s-ci-robot merged 10 commits into
kubernetes-sigs:mainfrom
shrutiyam-glitch:update-pss-client

Conversation

@shrutiyam-glitch

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Key Changes included:

  • The SnapshotFilter and list method in SnapshotEngine now support created_after and created_before parameters, allowing users to retrieve snapshots within a specific time range.
  • The delete_all method has been refactored to remove label-based deletion in favor of global deletion with optional timestamp filters.
  • The is_restored_from_snapshot method in SandboxWithSnapshotSupport has been made private (_is_restored_from_snapshot) to better align with the intended internal usage during the resume lifecycle.
  • Documentation and Test Updates: The snapshot documentation and test suites (unit and integration) have been updated to reflect these API changes and the shift toward the Suspend/Resume workflow.

Which issue(s) this PR is related to:

Contributes to #709 comments.

Release Note

@netlify

netlify Bot commented May 4, 2026

Copy link
Copy Markdown

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 1960e02
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/6a160776ba685e00084ebcd7
@k8s-ci-robot k8s-ci-robot requested review from barney-s and justinsb May 4, 2026 23:47
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 4, 2026
@shrutiyam-glitch

Copy link
Copy Markdown
Contributor Author

/assign @SHRUTI6991

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the Python PodSnapshot SDK extension to support filtering snapshots by creationTimestamp, simplifies snapshot deletion semantics, and aligns the documented workflow with the Suspend/Resume lifecycle.

Changes:

  • Added created_after / created_before filtering to SnapshotEngine.list() (and used it for scoped delete_all()).
  • Refactored snapshot deletion to remove label-based strategies in favor of “delete all (optionally within a time range)”.
  • Updated docs and tests to reflect Suspend/Resume restore semantics and the new filtering API.

Reviewed changes

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

Show a summary per file
File Description
site/content/docs/sandbox/snapshots/_index.md Updates the docs example to use suspend/resume and clarifies restore constraints.
clients/python/agentic-sandbox-client/test_podsnapshot_extension.py Adjusts the integration test to use the new list/delete APIs and exercises timestamp filtering.
clients/python/agentic-sandbox-client/k8s_agent_sandbox/gke_extensions/snapshots/test/unit/test_sandbox_with_snapshot_support.py Updates unit tests for the renamed restore-check helper and adds timestamp-filter list coverage.
clients/python/agentic-sandbox-client/k8s_agent_sandbox/gke_extensions/snapshots/snapshot_engine.py Implements timestamp filtering and refactors delete_all() to accept optional time bounds.
clients/python/agentic-sandbox-client/k8s_agent_sandbox/gke_extensions/snapshots/sandbox_with_snapshot_support.py Makes restore-check helper private and updates resume logic to use it.
clients/python/agentic-sandbox-client/k8s_agent_sandbox/gke_extensions/snapshots/README.md Updates extension docs for the new list/delete behavior and Suspend/Resume constraints.
Comment thread site/content/docs/sandbox/snapshots/_index.md Outdated
Comment thread clients/python/agentic-sandbox-client/test_podsnapshot_extension.py
Comment thread clients/python/agentic-sandbox-client/test_podsnapshot_extension.py Outdated
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 13, 2026
> Note: this example uses `simple-sandbox-template`, which you should create in your GKE cluster first. The associated resources can be found [here](https://github.com/volatilemolotov/agent-sandbox/tree/main/site/content/docs/sandbox/snapshots/source).

> [!NOTE]
> A sandbox can only be restored from its own previous snapshots (via the `suspend()` and `resume()` lifecycle). A new sandbox cannot be restored from the snapshot of another sandbox.

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.

I don't think we need to mention this "A new sandbox cannot be restored from the snapshot of another sandbox.".

Since alpha -> beta upgrades comes with no backward compatibility guarantees. I can add this in the migration doc if needed.

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.

Okay, sure.

@SHRUTI6991

Copy link
Copy Markdown
Contributor

/lgtm

One small comment.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
@SHRUTI6991

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
try:
creation_time = datetime.fromisoformat(creation_time_str.replace("Z", "+00:00"))
except ValueError:
creation_time = None

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.

I feel like we should not silently ignore an invalid creationTimestamp ?

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.

Added a warning for invalid timestamp on ps resource. Thanks !

@justinsb justinsb left a comment

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.

/approve
/lgtm

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb, SHRUTI6991, shrutiyam-glitch

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 26, 2026
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
@SHRUTI6991

Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2026
@k8s-ci-robot k8s-ci-robot merged commit bfbca8c into kubernetes-sigs:main May 26, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Agent Sandbox May 26, 2026
khirotaka pushed a commit to khirotaka/agent-sandbox that referenced this pull request Jun 12, 2026
…stamp (kubernetes-sigs#732)

* Remove grouping label

* Make is_restored method private

* Add filtering by creation timestamp

* Address comments

* Update delete_by

* Address comments

* Update Note

* Add warning for invalid timestamp in ps resource
alexatakvelon pushed a commit to volatilemolotov/agent-sandbox that referenced this pull request Jun 24, 2026
…stamp (kubernetes-sigs#732)

* Remove grouping label

* Make is_restored method private

* Add filtering by creation timestamp

* Address comments

* Update delete_by

* Address comments

* Update Note

* Add warning for invalid timestamp in ps resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ready-for-review size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

6 participants