:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): resume VM sandboxes from filesystem snapshots (#63043)
Alessandro Pogliaghi2da8432c8973
diff --git a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.pyindex b70e94ecbde2..522eb5cdf13c 100644--- a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py+++ b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py@@ -241,11 +241,9 @@ def prepare_sandbox_for_repository(input: PrepareSandboxForRepositoryInput) -> Phas_repo = ctx.repository is not Nonerepository = ctx.repository- snapshot_resume_disabled = ctx.use_modal_vm_sandbox-snapshot = Noneused_snapshot = False- if has_repo and ctx.github_integration_id is not None and not snapshot_resume_disabled:+ if has_repo and ctx.github_integration_id is not None:assert repository is not Nonewith StepTimer("snapshot_lookup") as snapshot_lookup_timer:snapshot = SandboxSnapshot.get_latest_snapshot_with_repos(ctx.github_integration_id, [repository])@@ -294,13 +292,12 @@ def prepare_sandbox_for_repository(input: PrepareSandboxForRepositoryInput) -> Penvironment_variables = _build_environment_variables(ctx, task, github_token, access_token)run_state = parse_run_state(ctx.state)- # When Modal resume snapshots are disabled, ignore any snapshot_external_id- # baked into TaskRun state — resume falls back to the agent server's- # git-checkpoint flow (POSTHOG_RESUME_RUN_ID continues to be set above).+ # VM and gVisor both resume from filesystem snapshots. A run's resume+ # snapshot is taken from the same task's sandbox, so its base image+ # matches the runtime provisioned here (the earlier disable was for+ # gVisor memory snapshots, which cannot restore into the VM runtime).resume_snapshot_external_id = (- run_state.snapshot_external_id- if settings.TASKS_USE_MODAL_RESUME_SNAPSHOTS and not snapshot_resume_disabled- else None+ run_state.snapshot_external_id if settings.TASKS_USE_MODAL_RESUME_SNAPSHOTS else None)if resume_snapshot_external_id:used_snapshot = True