Skip to content

Add None handling to sandbox/gateway/snapshot wait#414

Open
nadolskit wants to merge 3 commits intokubernetes-sigs:mainfrom
nadolskit:fix-nonetype-not-subscriptable
Open

Add None handling to sandbox/gateway/snapshot wait#414
nadolskit wants to merge 3 commits intokubernetes-sigs:mainfrom
nadolskit:fix-nonetype-not-subscriptable

Conversation

@nadolskit
Copy link

@nadolskit nadolskit commented Mar 13, 2026

Summary:

  • Adds a guard on wait functions of sandbox/add gateway/waiting for pods
  • The k8s watch api can yield None under misc conditions (such as network drops, timeouts, etc) causing 'NoneType' object is not subscriptable

Context:
as seen in our dev environment:

ERROR 2026-03-13 17:22:32,450 job_service [dispatch] sandbox error for 4a5ae8e3-adfe-4c1f-a2d3-760f115bba8a
Traceback (most recent call last):
  File "/app/packages/crow-service/crow_service/services/sandbox_client.py", line 384, in start
    await asyncio.to_thread(self._sync_client.start)
  File "/usr/local/lib/python3.12/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/packages/crow-service/crow_service/services/sandbox_client.py", line 170, in start
    SandboxClient.__enter__(self)  # noqa: PLC2801
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/k8s_agent_sandbox/sandbox_client.py", line 343, in __enter__
    self._wait_for_sandbox_ready()
  File "/app/.venv/lib/python3.12/site-packages/k8s_agent_sandbox/trace_manager.py", line 178, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/k8s_agent_sandbox/sandbox_client.py", line 198, in _wait_for_sandbox_ready
    if event["type"] in ["ADDED", "MODIFIED"]:
       ~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/packages/crow-service/crow_service/services/job_service.py", line 481, in dispatch_queued_job
    response: JSONResponse = await run_crow_job(
                             ^^^^^^^^^^^^^^^^^^^
  File "/app/packages/crow-service/crow_service/services/job_service.py", line 902, in run_crow_job
    await sandbox.start()
  File "/app/packages/crow-service/crow_service/services/sandbox_client.py", line 390, in start
    raise SandboxError(str(e)) from e
crow_service.services.sandbox_client.SandboxError: 'NoneType' object is not subscriptable

Resolves: #392

@netlify
Copy link

netlify bot commented Mar 13, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 6b6a32e
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69b8b0d9444af80008ee6a29

@k8s-ci-robot k8s-ci-robot requested review from igooch and janetkuo March 13, 2026 23:25
@k8s-ci-robot
Copy link
Contributor

Welcome @nadolskit!

It looks like this is your first PR to kubernetes-sigs/agent-sandbox 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/agent-sandbox has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 13, 2026
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 13, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Hi @nadolskit. 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 13, 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 Mar 17, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aditya-shantanu, nadolskit
Once this PR has been reviewed and has the lgtm label, please assign barney-s 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

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.

Crash with NoneType error when sandbox pods are unschedulable due to no available nodes

5 participants