Repository navigation
fix(daemon): a lane being forgotten no longer holds the main tree's down - #589
Merged
Merged
Conversation
When a lane's worktree is removed, the main tree's daemon forgets the
lane: its supervisor closes, its Compose projects and data are removed.
That takes a while (about 90 s seen with Docker Desktop on Windows), and
for all of it the lane sits in `pending`, which `active()` and
`any_local()` read as "started". So `devstack down` in the main tree
kept the containers and services that serve the lanes ("lanes run: x"),
and `devstack down --all` failed with "lane `x` is not started", because
`stop()` looks the lane up in `map`, which the forget had already left.
`active()` and `any_local()` now leave out the lanes in `forgetting`;
`any_running()` still counts them, so the forget keeps the daemon, and
`down_all()` lets a forget end before the daemon stops instead of
cutting it off half way. The MCP `lanes` tool says that such a lane is
being removed, as `devstack lane list` does.
Verification: the new unit test `a_lane_being_forgotten_is_not_started`
fails without the fix at `active()` (left ["gone"], right []), passes
with it; two wrong versions (no wait in `down_all`, `active()` without
any pending lane) fail it at their own assertion. fmt, clippy and the
tests of devstack-daemon and devstack in a Linux container.
Bug-Class: transition-read-as-running
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
A downstream user stopped a lane (
devstack downin its worktree), removed the worktree (git worktree remove), and randevstack downin the main tree right after. The main tree's daemon was still forgetting the lane (closing its supervisor, removing its Compose projects and data; about 90 s with Docker Desktop on Windows). For all of that time the lane sat inpending, whichactive()andany_local()read as "started":devstack downin the main tree kept the containers and services that serve the lanes (... removed but infra.a, infra.b, infra.c (lanes run: x)),devstack down --allfailed withdid not stop: lanex: lanexis not started, becausestop()looks the lane up inmap, which the forget had already left,lanestool did not list the lane at all, andstatussaid0 started, so nothing explained why.Daemon log of the case (names replaced):
Change
Lanes::active()andLanes::any_local()leave out lanes inforgetting: such a lane stops already, nothing is kept for it anddown --allhas nothing of it to stop. It is inpendingonly to keep a start out.Lanes::any_running()still counts it, so the forget keeps the daemon, andLanes::down_all()lets a forget end before the daemon stops (bounded by the shutdown's existingSHUTDOWN_STOP), instead of cutting it off with the lane's containers half removed. This also keeps a lane being forgotten out of the restart'scarry_now(), which logged it as "its start or move was under way".lanestool saysbeing removed (its worktree is gone), asdevstack lane listsaysremoving.No review card: a bug fix within ADR-0024 and ADR-0030 (lanes that run keep the daemon and what serves them); a lane being removed does not run. Decided on my own: the wait in
down_all(), and the MCP wording.Siblings
stop_all()during a lane's start (inpending, not yet inmap) still answers "is not started" for it. Left as it is: a start can be waited for or refused, which is a different decision.devstack downin a lane, arestart_onchange still restarts that lane's Compose containers (restart_containerdoes not check that the container runs; services skip with "it is not running"). Here it failed only because the worktree was gone (os error 267). Not changed here; worth an issue of its own.Verification
lanes::tests::a_lane_being_forgotten_is_not_started: red without the fix atactive()(left: ["gone"],right: []), green with it. Two wrong versions fail it at their own assertion: no wait indown_all()("down_all ended while a lane was being forgotten"), and anactive()that drops every pending lane (left: [],right: ["next"]).cargo fmt --all -- --check,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo test -p devstack-daemon --lib(221 passed) andcargo test -p devstack --bins, in a Linux container (rust:latest): the Windows machine's MSVC toolset was incomplete at the time. Windows runs in CI.🤖 Generated with Claude Code