fix: resolve teardown timeout before registration to prevent orphaned state
tracker-policy-pr / check-pr (pull_request) Successful in 12s
test / integration-docker (pull_request) Successful in 15s
test / unit (pull_request) Successful in 39s
test / stage-firecracker-inputs (pull_request) Successful in 1s
lint / lint (push) Failing after 2m36s
test / build-infra (pull_request) Successful in 4m13s
test / integration-firecracker (pull_request) Successful in 1m30s
test / coverage (pull_request) Successful in 2m12s
test / publish-infra (pull_request) Has been skipped

If resolve_teardown_timeout() raised after launch_consolidated()/register_agent()
returned, the teardown callback was never registered, leaving the bottle
registered with no cleanup path. Resolve the timeout into a local variable
before the registration call so any failure aborts before the bottle exists.

Add tests covering OrchestratorConfigStore, resolve_teardown_timeout priority
ordering (env > db > default), and the source-order invariant that the resolver
runs before registration in all three backends.
This commit is contained in:
2026-07-21 04:09:20 +00:00
parent 3674d7780b
commit 31000dcbe3
4 changed files with 155 additions and 3 deletions
+2 -1
View File
@@ -134,13 +134,14 @@ def launch(
token_values = egress_resolve_token_values(
plan.egress_plan.token_env_map, effective_env,
)
teardown_timeout = resolve_teardown_timeout()
ctx = launch_consolidated(
plan.egress_plan, git_gate_plan, image_ref=plan.image, tokens=token_values,
)
stack.callback(
teardown_consolidated, ctx.bottle_id,
orchestrator_url=ctx.orchestrator_url,
timeout=resolve_teardown_timeout(),
timeout=teardown_timeout,
)
# Step 4: install the SHARED gateway CA into the agent (replaces the
+2 -1
View File
@@ -113,6 +113,7 @@ def launch(
token_values = egress_resolve_token_values(
plan.egress_plan.token_env_map, effective_env,
)
teardown_timeout = resolve_teardown_timeout()
ctx = launch_consolidated(
plan.egress_plan, git_gate_plan,
guest_ip=slot.guest_ip,
@@ -122,7 +123,7 @@ def launch(
stack.callback(
teardown_consolidated, ctx.bottle_id,
orchestrator_url=ctx.orchestrator_url,
timeout=resolve_teardown_timeout(),
timeout=teardown_timeout,
)
# Step 5: install the SHARED gateway CA (replaces the per-bottle CA).
+2 -1
View File
@@ -130,6 +130,7 @@ def launch(
token_values = egress_resolve_token_values(
plan.egress_plan.token_env_map, effective_env,
)
teardown_timeout = resolve_teardown_timeout()
ctx = register_agent(
plan.egress_plan,
plan.git_gate_plan,
@@ -141,7 +142,7 @@ def launch(
stack.callback(
teardown_consolidated, ctx.bottle_id,
orchestrator_url=ctx.orchestrator_url,
timeout=resolve_teardown_timeout(),
timeout=teardown_timeout,
)
info(
f"agent {plan.container_name} registered "