Skip to content

Enhanced Pod Snapshot Management (Persistence, List, Delete)#312

Draft
shrutiyam-glitch wants to merge 16 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:pss-sdk-phase-2
Draft

Enhanced Pod Snapshot Management (Persistence, List, Delete)#312
shrutiyam-glitch wants to merge 16 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:pss-sdk-phase-2

Conversation

@shrutiyam-glitch
Copy link
Contributor

@shrutiyam-glitch shrutiyam-glitch commented Feb 12, 2026

Depends on: #249

This PR extends the PodSnapshotSandboxClient to support the full lifecycle of pod snapshots, introducing local metadata persistence, listing capabilities, and deletion logic.

Key Changes:

  • Snapshot Persistence (SnapshotPersistenceManager):
    -- Added local metadata storage (~/.snapshot_metadata/.snapshots.json) to track created snapshots.
    -- Metadata includes snapshot_uid, creationTimestamp, policy_labels, policy_name and claim_name.
    -- The snapshot() method now automatically saves snapshot metadata upon successful creation.
  • list_snapshots():
    -- Lists valid snapshots from local metadata. Supports filtering by policy_name and ready_only status.
    -- Returns a list of dictionaries sorted by creation timestamp (newest first).
  • delete_snapshots():
    -- Deletes both the PodSnapshot resources from the cluster.
    -- Cleans up the corresponding local metadata.
    -- Returns the total count of successfully deleted snapshots.
    -- Can delete a specific snapshot by snapshot_uid or ALL tracked snapshots if no name is provided.

Helper Methods:

  • Added _get_policy_info to fetch labels from the PodSnapshot and PodSnapshotPolicy resources for metadata storage.

Testing:

  • Unit Tests: Added
    agentic_sandbox/gke_extensions/test_podsnapshot_client.py

  • Integration Test:
    -- Updated test_podsnapshot_extension.py to verify the new listing and deletion workflows.
    -- Lists existing ready snapshots after creation.
    -- Deletes all snapshots at the end of the test and verifies the deletion count.

Output:

python3 test_podsnapshot_extension.py --labels app=agent-sandbox-workload --template-name python-counter-template --namespace sandbox-test
--- Starting Sandbox Client Test (Namespace: sandbox-test, Port: 8888) ---

***** Phase 1: Starting Counter *****

======= Testing Pod Snapshot Extension =======
Creating first pod snapshot 'test-snapshot-10' after 10 seconds...
Trigger Name: test-snapshot-10-42155a16
Snapshot UID: f0a06afd-2b9a-4f03-bf0e-db18da33881f
Success: True
Error Code: 0
Error Reason: 

Creating second pod snapshot 'test-snapshot-20' after 10 seconds...
Trigger Name: test-snapshot-20-963ea265
Snapshot UID: 385eb33e-6d81-4515-9ce8-16bd810003a6
Success: True
Error Code: 0
Error Reason: 
Recent snapshot UID: 385eb33e-6d81-4515-9ce8-16bd810003a6

***** List all existing ready snapshots with the policy name. *****
Snapshot ID: 385eb33e-6d81-4515-9ce8-16bd810003a6, Source Pod: sandbox-claim-ce2c1e4a, Creation Time: 2026-02-19T22:57:12Z, Policy Name: example-psp-workload
Snapshot ID: f0a06afd-2b9a-4f03-bf0e-db18da33881f, Source Pod: sandbox-claim-ce2c1e4a, Creation Time: 2026-02-19T22:56:59Z, Policy Name: example-psp-workload

***** Phase 2: Restoring from most recent snapshot & Verifying *****

Waiting 5 seconds for restored pod to resume printing...
Pod was restored from the most recent snapshot.

**** Deleting snapshots *****
Deleted Snapshots: 2
--- Pod Snapshot Test Passed! ---

--- Sandbox Client Test Finished ---

@netlify
Copy link

netlify bot commented Feb 12, 2026

Deploy Preview for agent-sandbox ready!

Name Link
🔨 Latest commit 18b8920
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/6997983de198260008f6e00c
😎 Deploy Preview https://deploy-preview-312--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
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shrutiyam-glitch
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.

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

@shrutiyam-glitch shrutiyam-glitch marked this pull request as draft February 12, 2026 20:15
@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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 12, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @shrutiyam-glitch. 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.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 12, 2026
@janetkuo janetkuo 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 Feb 12, 2026
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2026
@k8s-ci-robot
Copy link
Contributor

@shrutiyam-glitch: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
presubmit-agent-sandbox-unit-test 756a4c4 link true /test presubmit-agent-sandbox-unit-test
presubmit-test-autogen-up-to-date 756a4c4 link true /test presubmit-test-autogen-up-to-date
presubmit-agent-sandbox-e2e-test 756a4c4 link true /test presubmit-agent-sandbox-e2e-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2026
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 24, 2026
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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants