diff --git a/api/core/sandbox/builder.py b/api/core/sandbox/builder.py index 6ec2bd38aa..efb7e88c9b 100644 --- a/api/core/sandbox/builder.py +++ b/api/core/sandbox/builder.py @@ -175,11 +175,11 @@ class SandboxBuilder: if sandbox.is_cancelled(): return - # Storage mount is part of readiness. If restore/mount fails, - # the sandbox must surface initialization failure instead of - # becoming "ready" with missing files. - if not sandbox.mount(): - raise RuntimeError("Sandbox storage mount failed") + # Attempt to restore prior workspace state. mount() returns + # False when no archive exists yet (first run for this + # sandbox_id), which is a normal case — not an error. + # Actual failures (download/extract) surface as exceptions. + sandbox.mount() sandbox.mark_ready() except Exception as exc: try: diff --git a/api/core/sandbox/storage/archive_storage.py b/api/core/sandbox/storage/archive_storage.py index bdc8e2021b..2f6c436cad 100644 --- a/api/core/sandbox/storage/archive_storage.py +++ b/api/core/sandbox/storage/archive_storage.py @@ -4,7 +4,6 @@ from __future__ import annotations import logging -from core.virtual_environment.__base.exec import PipelineExecutionError from core.virtual_environment.__base.helpers import pipeline from core.virtual_environment.__base.virtual_environment import VirtualEnvironment from extensions.storage.base_storage import BaseStorage @@ -47,19 +46,15 @@ class ArchiveSandboxStorage(SandboxStorage): download_url = self._storage.get_download_url(self._storage_key, _ARCHIVE_TIMEOUT) archive = "archive.tar.gz" - try: - ( - pipeline(sandbox) - .add(["curl", "-fsSL", download_url, "-o", archive], error_message="Failed to download archive") - .add( - ["sh", "-c", 'tar -xzf "$1" 2>/dev/null; exit $?', "sh", archive], error_message="Failed to extract" - ) - .add(["rm", archive], error_message="Failed to cleanup") - .execute(timeout=_ARCHIVE_TIMEOUT, raise_on_error=True) + ( + pipeline(sandbox) + .add(["curl", "-fsSL", download_url, "-o", archive], error_message="Failed to download archive") + .add( + ["sh", "-c", 'tar -xzf "$1" 2>/dev/null; exit $?', "sh", archive], error_message="Failed to extract" ) - except PipelineExecutionError: - logger.exception("Failed to mount archive for sandbox %s", self._sandbox_id) - return False + .add(["rm", archive], error_message="Failed to cleanup") + .execute(timeout=_ARCHIVE_TIMEOUT, raise_on_error=True) + ) logger.info("Mounted archive for sandbox %s", self._sandbox_id) return True