Skip to content

Comments

feat: implement pod snapshot method#339

Open
shrutiyam-glitch wants to merge 3 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:pss_sdk_snapshot
Open

feat: implement pod snapshot method#339
shrutiyam-glitch wants to merge 3 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:pss_sdk_snapshot

Conversation

@shrutiyam-glitch
Copy link
Contributor

Depends on: #338 #337

This PR completes the Pod Snapshot extension for the Python SDK by implementing the snapshot() method and the underlying logic to monitor snapshot completion.

Core Logic Implementation:

  • Manual Trigger Workflow: The snapshot() method creates a PodSnapshotManualTrigger resource for the target pod, using a unique hash suffix to avoid name collisions.
  • Snapshot Status Watcher: Implements _wait_for_snapshot_processed, which uses the Kubernetes watch API to block until the snapshot controller marks the trigger as Complete. It specifically looks for the Triggered condition with a True status and Complete reason.
  • Response Handling: Captures the snapshot_uid from the resource status and returns a structured SnapshotResponse, providing the user with the unique identifier needed for future restores.
  • Lifecycle Cleanup: Updates the __exit__ method to ensure that all PodSnapshotManualTrigger resources created during the session are automatically deleted, maintaining a clean namespace.

Testing Done:

  • Integration Test: Added test_podsnapshot_extension.py which verifies the full E2E flow:
    -- Starts a sandbox with a counter application.
    -- Creates two sequential snapshots (test-snapshot-10 at 10 seconds and test-snapshot-20 at 20 seconds).

  • Unit tests are added

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-890451fd
Snapshot UID: 8a72cd17-7e70-4c3c-beb2-f62ae642faed
Success: True
Error Code: 0
Error Reason: 

Creating second pod snapshot 'test-snapshot-20' after 10 seconds...
Trigger Name: test-snapshot-20-ce4fe530
Snapshot UID: a15ee9e1-5939-4110-a1e9-ce4828874734
Success: True
Error Code: 0
Error Reason: 
Recent snapshot UID: a15ee9e1-5939-4110-a1e9-ce4828874734

--- Pod Snapshot Test Passed! ---

--- Sandbox Client Test Finished ---

@netlify
Copy link

netlify bot commented Feb 21, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit e5824b0
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69990ab29449860008ab0d3b

@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

@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 Feb 21, 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 21, 2026
@janetkuo
Copy link
Member

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants