Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

fix(server): serve Sandbox CR reads for fsb snapshot encoding detection

高然54d1224e6c60
diff --git a/server/opensandbox_server/services/fast_sandbox/snapshot_runtime.py b/server/opensandbox_server/services/fast_sandbox/snapshot_runtime.py
index 1ef880de6..a192b55a9 100644
--- a/server/opensandbox_server/services/fast_sandbox/snapshot_runtime.py
+++ b/server/opensandbox_server/services/fast_sandbox/snapshot_runtime.py
@@ -218,7 +218,11 @@ class FastSandboxSnapshotRuntime:
"""
try:
cr = self._k8s_client.get_custom_object(
- GROUP, VERSION, namespace, SANDBOX_PLURAL, sandbox_id
+ group=GROUP,
+ version=VERSION,
+ namespace=namespace,
+ plural=SANDBOX_PLURAL,
+ name=sandbox_id,
)
except Exception as exc: # noqa: BLE001 - any read failure blocks the branch decision
logger.warning(
diff --git a/server/tests/test_snapshot_ha_postgresql_kubernetes.py b/server/tests/test_snapshot_ha_postgresql_kubernetes.py
index c9285f6c1..4f65a672e 100644
--- a/server/tests/test_snapshot_ha_postgresql_kubernetes.py
+++ b/server/tests/test_snapshot_ha_postgresql_kubernetes.py
@@ -171,6 +171,9 @@ class _SharedK8sClient:
self._delete_barrier = Barrier(2) if force_create_conflict else None
self.objects: dict[str, dict] = {}
self.workloads = {SANDBOX_ID: {}}
+ # fsb snapshot creation classifies the artifact encoding by reading
+ # the source Sandbox CR; native image keeps template_name semantics.
+ self.sandboxes = {FSB_SANDBOX_ID: {"spec": {"image": "alpine:3.19"}}}
self.pods = {
f"{SANDBOX_ID}-0": {
"spec": {},
@@ -207,6 +210,12 @@ class _SharedK8sClient:
workload = self.workloads.get(name)
return deepcopy(workload) if workload is not None else None
+ if plural == "sandboxes":
+ cr = self.sandboxes.get(name)
+ if cr is None:
+ raise ApiException(status=404, reason="Not Found")
+ return deepcopy(cr)
+
barrier = None
with self._lock:
if self._observe_count < len(self._observe_barriers) * 2: