Skip to content

Comments

Add status method to Sandbox Client and also add unit tests associated with it.#280

Open
SHRUTI6991 wants to merge 2 commits intokubernetes-sigs:mainfrom
SHRUTI6991:core_execution_pod_status
Open

Add status method to Sandbox Client and also add unit tests associated with it.#280
SHRUTI6991 wants to merge 2 commits intokubernetes-sigs:mainfrom
SHRUTI6991:core_execution_pod_status

Conversation

@SHRUTI6991
Copy link
Contributor

Description

This PR adds two changes:

  1. New status method which returns the SandboxStatus. It internally calls the K8 API to check the status of the Pod.
  2. Unit tests associated with the sandbox_client.

Testing Logs

--- Starting Sandbox Client Test (Namespace: default, Port: 8888) ---
Mode: Local Port-Forward fallback

--- Testing Pod Name Discovery ---
Pod name annotation not found, falling back to sandbox name.
--- Pod Name Discovery Test Passed (Fallback) ---

--- Testing Sandbox Status ---
Sandbox status: Running
--- Sandbox Status Test Passed ---

--- Testing Command Execution ---
Executing command: 'echo 'Hello from the sandbox!''
Stdout: Hello from the sandbox!
Stderr: 
Exit Code: 0

--- Command Execution Test Passed! ---

--- Testing File Operations ---
Writing content to 'test.txt'...
Reading content from 'test.txt'...
Read content: 'This is a test file.'

@netlify
Copy link

netlify bot commented Feb 3, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 9cecb36
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/698caf2e2a66a7000809e25c

@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 3, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @SHRUTI6991. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 3, 2026
@SHRUTI6991
Copy link
Contributor Author

/assign @barney-s

@janetkuo
Copy link
Member

janetkuo commented Feb 5, 2026

/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 5, 2026
return SandboxStatus.SANDBOX_NOT_CREATED

try:
v1 = client.CoreV1Api()
Copy link
Member

Choose a reason for hiding this comment

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

Could we move it outside of status() to reduce overhead?

span.set_attribute("sandbox.name", self.claim_name)

if not self.claim_name:
return SandboxStatus.SANDBOX_NOT_CREATED
Copy link
Member

Choose a reason for hiding this comment

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

self.claim_name could be None when SandboxClient is initialized with api_url, so it's misleading to report SandboxNotCreated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am curious, wouldn't the __enter__ method initialize the claim_name with a different claim_name if only api_url is provided.

For this PR, I have removed this check and currently only calling the API to report the accurate status.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aditya-shantanu, SHRUTI6991
Once this PR has been reviewed and has the lgtm label, please ask for approval from barney-s. 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
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 18, 2026
format='%(asctime)s - %(levelname)s - %(message)s',
stream=sys.stdout)

class SandboxStatus(Enum):
Copy link
Member

Choose a reason for hiding this comment

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

If i'm not mistaken, this PR will be affected by this one #121 , right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice, we are exposing the Sandbox status directly. Yes let me hold on to my current PR.

@k8s-ci-robot
Copy link
Contributor

@SHRUTI6991: 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-test-autogen-up-to-date 9cecb36 link true /test presubmit-test-autogen-up-to-date
presubmit-agent-sandbox-unit-test 9cecb36 link true /test presubmit-agent-sandbox-unit-test
presubmit-agent-sandbox-e2e-test 9cecb36 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.

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. 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/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.

6 participants