diff --git a/bot_bottle/backend/consolidated_util.py b/bot_bottle/backend/bottle_provision.py similarity index 80% rename from bot_bottle/backend/consolidated_util.py rename to bot_bottle/backend/bottle_provision.py index 04b4025..c18435b 100644 --- a/bot_bottle/backend/consolidated_util.py +++ b/bot_bottle/backend/bottle_provision.py @@ -1,8 +1,10 @@ -"""Shared helpers for the consolidated launch sequence (PRD 0070). +"""Bottle-level provisioning for the consolidated launch sequence (PRD 0070). -Logic that was duplicated across the docker, macos_container, and -firecracker consolidated_launch modules — extracted so each backend -imports it rather than re-implementing it. +Register a bottle with the orchestrator and provision its git-gate state into +the shared gateway (`provision_bottle`), and the inverse teardown +(`deprovision_bottle`). Backend-neutral — each backend's consolidated_launch +drives these through its own `GatewayTransport` rather than re-implementing +them. The git-gate half of the work lives in `gateway_provision`. """ from __future__ import annotations @@ -49,7 +51,7 @@ def provision_bottle( return dataclasses.replace(reg, env_var_secret=env_var_secret) -def teardown_consolidated( +def deprovision_bottle( bottle_id: str, transport: GatewayTransport, *, @@ -66,4 +68,4 @@ def teardown_consolidated( deprovision_git_gate(transport, bottle_id) -__all__ = ["provision_bottle", "teardown_consolidated"] +__all__ = ["provision_bottle", "deprovision_bottle"] diff --git a/bot_bottle/backend/docker/consolidated_launch.py b/bot_bottle/backend/docker/consolidated_launch.py index bce49ab..633da99 100644 --- a/bot_bottle/backend/docker/consolidated_launch.py +++ b/bot_bottle/backend/docker/consolidated_launch.py @@ -24,8 +24,7 @@ from ...gateway import GATEWAY_NETWORK from .infra import INFRA_NAME, DockerInfraService from ...orchestrator.store.secret_store import ENV_VAR_SECRET_NAME from ...orchestrator.reprovision import reprovision_bottles -from ..consolidated_util import provision_bottle -from ..consolidated_util import teardown_consolidated as _teardown_util +from ..bottle_provision import deprovision_bottle, provision_bottle from .gateway_transport import DockerGatewayTransport from .gateway_net import next_free_ip @@ -174,7 +173,7 @@ def teardown_consolidated( timeout: float | None = None, ) -> None: """Deregister the bottle and remove its git-gate state. Idempotent.""" - _teardown_util(bottle_id, DockerGatewayTransport(infra_name), + deprovision_bottle(bottle_id, DockerGatewayTransport(infra_name), orchestrator_url=orchestrator_url, timeout=timeout) diff --git a/bot_bottle/backend/firecracker/consolidated_launch.py b/bot_bottle/backend/firecracker/consolidated_launch.py index e2b46d5..ed7de77 100644 --- a/bot_bottle/backend/firecracker/consolidated_launch.py +++ b/bot_bottle/backend/firecracker/consolidated_launch.py @@ -40,10 +40,7 @@ from ...orchestrator.lifecycle import ( ) from ...orchestrator.reprovision import reprovision_bottles from ...orchestrator.store.secret_store import ENV_VAR_SECRET_NAME -from ..consolidated_util import ( - provision_bottle, - teardown_consolidated as _teardown_util, -) +from ..bottle_provision import deprovision_bottle, provision_bottle from . import cleanup, infra_vm, util from .gateway import FirecrackerGateway @@ -156,7 +153,7 @@ def teardown_consolidated( VM. Both steps are idempotent so this is safe from a cleanup trap. Does NOT stop the infra VMs — they're persistent per-host singletons shared by every bottle.""" - _teardown_util(bottle_id, FirecrackerGateway().provisioning_transport(), + deprovision_bottle(bottle_id, FirecrackerGateway().provisioning_transport(), orchestrator_url=orchestrator_url, timeout=timeout) diff --git a/bot_bottle/backend/macos_container/consolidated_launch.py b/bot_bottle/backend/macos_container/consolidated_launch.py index e197a2b..5c2c839 100644 --- a/bot_bottle/backend/macos_container/consolidated_launch.py +++ b/bot_bottle/backend/macos_container/consolidated_launch.py @@ -40,10 +40,7 @@ from ...log import info from ...orchestrator.client import OrchestratorClient, OrchestratorClientError from ...orchestrator.reprovision import reprovision_bottles from ...orchestrator.store.secret_store import ENV_VAR_SECRET_NAME -from ..consolidated_util import ( - provision_bottle, - teardown_consolidated as _teardown_util, -) +from ..bottle_provision import deprovision_bottle, provision_bottle from . import util as container_mod from .enumerate import CONTAINER_NAME_PREFIX, EnumerationError, enumerate_active from .gateway import GATEWAY_NETWORK @@ -193,7 +190,7 @@ def teardown_consolidated( """Deregister the bottle and remove its git-gate state from the gateway. Both steps are idempotent so this is safe from a cleanup trap. Does NOT stop the gateway — it's a persistent per-host singleton.""" - _teardown_util(bottle_id, MacosGatewayTransport(), + deprovision_bottle(bottle_id, MacosGatewayTransport(), orchestrator_url=orchestrator_url, timeout=timeout) diff --git a/tests/unit/test_consolidated_launch.py b/tests/unit/test_consolidated_launch.py index 50b8243..68403bc 100644 --- a/tests/unit/test_consolidated_launch.py +++ b/tests/unit/test_consolidated_launch.py @@ -15,7 +15,7 @@ from bot_bottle.git_gate import GitGatePlan from bot_bottle.orchestrator.client import RegisteredBottle _MOD = "bot_bottle.backend.docker.consolidated_launch" -_UTIL = "bot_bottle.backend.consolidated_util" +_UTIL = "bot_bottle.backend.bottle_provision" def _egress_plan() -> EgressPlan: diff --git a/tests/unit/test_macos_consolidated_launch.py b/tests/unit/test_macos_consolidated_launch.py index 812e14e..743d795 100644 --- a/tests/unit/test_macos_consolidated_launch.py +++ b/tests/unit/test_macos_consolidated_launch.py @@ -17,7 +17,7 @@ from bot_bottle.git_gate import GitGatePlan from bot_bottle.orchestrator.client import RegisteredBottle _MOD = "bot_bottle.backend.macos_container.consolidated_launch" -_UTIL = "bot_bottle.backend.consolidated_util" +_UTIL = "bot_bottle.backend.bottle_provision" def _egress_plan() -> EgressPlan: