fix(gateway): persist git-gate state across gateway restarts
tracker-policy-pr / check-pr (pull_request) Successful in 12s
lint / lint (push) Successful in 59s
test / unit (pull_request) Successful in 53s
test / integration-docker (pull_request) Successful in 1m7s
test / coverage (pull_request) Successful in 19s

Per-bottle git-gate state (bare repos under /git/<id>, deploy creds under
/git-gate/creds/<id>) was provisioned once at bottle launch and lived only
in the gateway's ephemeral storage. A gateway rebuild/restart wiped it and
nothing re-provisioned already-running bottles, so their agents 404'd on
fetch/push. Same class of bug as the CA (#510); the orchestrator restores
only egress tokens, not git-gate declarations.

Persist the state on both backends, mirroring the CA-persistence approach:

- firecracker: attach a second persistent data drive (/dev/vdc) to the
  gateway VM and bind-mount its git/ + creds/ subdirs onto /git and
  /git-gate/creds in the gateway guest init, before the data plane starts.
  Generalize the VM config to a stable-ordered data_drives tuple (CA=vdb,
  git=vdc; orchestrator registry stays vdb).
- docker: bind-mount host dirs (host_gateway_git_dir / creds_dir, under the
  never-pruned app-data root) onto /git and /git-gate/creds, with
  BOT_BOTTLE_DOCKER_GIT_MOUNT / _CREDS_MOUNT env overrides so CI isolates
  them to per-run volumes it cleans up.

Teardown already rm -rf's /git/<id> + creds, so the persistent store
self-cleans over the normal lifecycle.

Closes #512

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 17:34:22 -04:00
parent 0ddaa95c14
commit dff811f190
13 changed files with 213 additions and 27 deletions
+12
View File
@@ -66,6 +66,18 @@ class TestRoleInits(unittest.TestCase):
self.assertIn(f"mount -t ext4 /dev/vdb {infra_vm._GATEWAY_CA_MOUNT}", init)
self.assertLess(init.index("/dev/vdb"),
init.index("bot_bottle.gateway.bootstrap"))
# Persistent git-gate volume (/dev/vdc) bind-mounted onto /git and
# /git-gate/creds so per-bottle repos + creds survive a rebuild (#512),
# also before the data plane (and any provisioning writes).
self.assertIn(f"mount -t ext4 /dev/vdc {infra_vm._GATEWAY_GIT_MOUNT}", init)
self.assertIn(
f"mount --bind {infra_vm._GATEWAY_GIT_MOUNT}/git "
f"{infra_vm._GATEWAY_GIT_REPO_ROOT}", init)
self.assertIn(
f"mount --bind {infra_vm._GATEWAY_GIT_MOUNT}/creds "
f"{infra_vm._GATEWAY_GIT_CREDS_DIR}", init)
self.assertLess(init.index("/dev/vdc"),
init.index("bot_bottle.gateway.bootstrap"))
self.assertIn("export PATH=", init) # shared preamble
self.assertIn("BOT_BOTTLE_GATEWAY_DAEMONS=egress,git-http,supervise", init)
self.assertIn(f"cat {infra_vm._GUEST_GATEWAY_JWT_PATH}", init) # host-minted JWT