Skip to content

feat(compose): AdoptExisting — reattach existing containers on resume - #120

Merged
bilby91 merged 1 commit into
mainfrom
feat/resume-adopt-existing
Aug 24, 2026
Merged

feat(compose): AdoptExisting — reattach existing containers on resume#120
bilby91 merged 1 commit into
mainfrom
feat/resume-adopt-existing

Conversation

@bilby91

@bilby91 bilby91 commented Aug 24, 2026

Copy link
Copy Markdown
Member

Adds UpOptions.AdoptExisting: on Up, reuse any existing (project, service) container unconditionally — start it if stopped, attach if running, and never recreate on config-hash drift.

Why: recreation abandons the containers' writable upperdirs and binds fresh anonymous volumes, which is where a workspace's real state lives (postgres/rabbitmq/minio data). The primary's feature-layered image gets a fresh digest every boot, so hash-based reuse can never match on resume; adoption ignores the hash when the caller says the on-disk state is authoritative.

Consumer: crunchloop/dap feat/runtime-state-topology (crunchloop/dap#4865) sets it on session resume. Validated end to end there (2026-08-24, three-leg round trip on kata + NVMe): the same primary container id survived cold boot → cross-node block-level restore → in-place pod restart, with $HOME upperdir state and anonymous-volume postgres rows intact across all three.

dap currently pins this branch's pseudo-version; merging this and tagging v0.4.3 unblocks that PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an option to reuse existing service containers even when configuration or image details have changed.
    • Stopped containers are started automatically, while running containers are reused without recreation.
    • Recreate mode continues to force container replacement when explicitly enabled.

…unconditionally

On resume, a restored workspace's containers must be reattached exactly as
left. The primary service's feature-layered image is rebuilt every boot with
a fresh digest, so the config-hash always drifts and ensureService recreates
it — abandoning the container's writable upperdir and binding a new empty
anonymous volume (the postgres data, the in-container $HOME). New
UpOptions.AdoptExisting (threaded to compose.Plan) makes ensureService reuse
any existing (project,service) container unconditionally: start if stopped,
attach if running, never recreate. Gated to non-recreate Ups. Default path
(hash-based reuse/recreate) unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ddbc1d-fe8a-4838-b17a-ba0191afc46d

📥 Commits

Reviewing files that changed from the base of the PR and between 1e67951 and 0e14b9b.

📒 Files selected for processing (4)
  • compose/orchestrator.go
  • compose/orchestrator_test.go
  • compose/plan.go
  • up.go

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The compose flow adds AdoptExisting options. When enabled, existing containers are reused and stopped containers are started without hash or image-digest reconciliation. Recreate disables adoption.

Changes

Existing Container Adoption

Layer / File(s) Summary
Adoption contract and orchestration wiring
up.go, compose/plan.go
UpOptions.AdoptExisting and Plan.AdoptExisting define adoption behavior. Native compose orchestration enables it only when Recreate is false.
Container reuse and regression coverage
compose/orchestrator.go, compose/orchestrator_test.go
ensureService starts or reattaches existing containers without drift checks when adoption is enabled. Tests cover adoption and default hash-drift recreation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 0e14b

The change adds opt-in reuse of existing containers during resume, preserving their state instead of recreating them. No actionable merge-blocking risk remains based on the supplied evidence.

Sequence Diagram(s)

sequenceDiagram
  participant UpOptions
  participant ComposePlan
  participant ensureService
  participant Container
  UpOptions->>ComposePlan: Pass AdoptExisting when Recreate is false
  ComposePlan->>ensureService: Provide adoption setting
  ensureService->>Container: Reuse existing container
  alt Container is stopped
    ensureService->>Container: Start container
  else Container is running
    ensureService->>Container: Reattach to container
  end
Loading

Poem

I’m a rabbit with a container plan,
Reusing what already ran.
Stale hashes no longer sway,
Stopped services wake and stay.
Hop, compose, and start the day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes reattaching existing containers through the new AdoptExisting feature.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/resume-adopt-existing

Comment @coderabbitai help to get the list of available commands.

@bilby91
bilby91 merged commit e46401a into main Aug 24, 2026
19 checks passed
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