Skip to content

fix(deploy): confirm fleet adoption before post-upload migrations - #217

Merged
ryuzdev merged 1 commit into
mainfrom
fix/migrate-after-adoption
Dec 1, 2026
Merged

ryuzdev merged 1 commit into
mainfrom
fix/migrate-after-adoption

Conversation

@ryuzdev

@ryuzdev ryuzdev commented Dec 1, 2026

Copy link
Copy Markdown
Member

Bug: a deploy that newly declares a D1 database failed. AfterUpload orders run cello_migrate right after the upload (pipeline.rs run_steps), but the fleet only adopts the new generation on its pointer poll (~30 s, cello generation.rs poll_interval; Outer nudges with POST /reload in fleet/supervisor.rs). So d1 migrations apply ran against the OLD generation, which has no __D1Database class, and failed with RestoreFailed.

Mechanism: cello's POST /reload adopts synchronously and reports the outcome (internal_reload in cello main.rs: 200 {ok, outcome: adopted|unchanged, generation, version}, 422 {ok:false, outcome:failed, error}). The new confirm_adoption gate runs after the wake inside migrate(), only for AfterUpload orders and only when migrations will actually apply (all early skips return before any fleet contact, so no-migration deploys are untouched). It POSTs /reload with min(step_timeout, 60 s) and requires the reported version to match the uploaded deployment version before cello d1 runs. A stale or refusing fleet fails the migrate step with 'fleet still serves version X, expected Y; migrations not applied' (apply never runs); an unreachable fleet fails only when a fleet manager exists, preserving the operator CLI first-deploy lease hint.

Timeout: 60 s bound (ADOPTION_TIMEOUT), effective timeout is min(step_timeout, 60 s). The POST blocks while the node builds the new generation.

Checks: cargo fmt --all --check, cargo clippy --all-targets --locked -- -D warnings, cargo test deploy:: fleet:: (168 passed), blume build --isolated + validate. New tests: migrate_waits_for_adoption_after_upload, migrate_refuses_a_stale_generation_after_upload, migrate_without_a_reachable_fleet_still_applies_after_upload, reload_report_times_out_against_a_hanging_fleet.

- After the upload publishes deploy/current.json, an awake fleet only adopts it on its pointer poll (~30 s), so cello d1 ran against the old generation (no __D1Database class) and failed with RestoreFailed.
- For AfterUpload orders, POST /reload (synchronous; block up to 60 s) and require the reported version to match the uploaded one before running cello d1. Stale or refused generations fail the migrate step without applying; unreachable fleets fail only when a fleet manager exists, preserving the operator CLI first-deploy path.
- The gate runs only when migrations will actually apply: all early skips return before any fleet contact.
- Tests: fake fleet listener asserting reload-before-apply order, stale-version refusal with no apply, unreachable-fleet fallback, and reload timeout. Docs: agents/deploy/pipeline.md, agents/backend/database.md.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02a954d3-d08c-4f31-8bd6-dc1720e850c0
Commits

Reviewing files that changed from the base of the PR and between 32f3bf0 and 79d2505.

Files selected for processing: 3

  • crates/outer/src/deploy/pipeline.rs
  • web/docs/agents/backend/database.md
  • web/docs/agents/deploy/pipeline.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ryuzdev
ryuzdev merged commit c138665 into main Dec 1, 2026
5 checks passed
@ryuzdev
ryuzdev deleted the fix/migrate-after-adoption branch December 1, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant