Skip to content

plan: a stopped service is started, not a blocker - #103

Merged
wmantly merged 1 commit into
mainfrom
feat/start-stopped
Nov 13, 2026
Merged

wmantly merged 1 commit into
mainfrom
feat/start-stopped

Conversation

@wmantly

@wmantly wmantly commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #101 (state: stopped|running): stopping a service still dead-ended the fleet, in two ways.

The bug

A stopped container has no IPv4 address, so the route check reports

! twenty (blocked)
    BLOCKED: twenty has no IPv4 address (is it stopped?), so apply could not
    health-check it or route to it

and a blocked plan is refused whole (the plan is blocked; nothing was applied).

1. Resume is blocked. state: stopped removed (or set to running) adds start, then falls through to the route check and blocks. The deploy meant to bring the service back never runs. TestExplicitRunningStartsStopped misses it because it asserts only the change kinds, not the blockers.

2. Anything stopped without a state: blocks everyone. A host reboot, a manual stop, or a manifest written before the field existed. Nothing is planned to start it, and because the plan is refused whole, every other service in the fleet cannot deploy. That is how a stopped twenty blocked a crew roll.

The fix

Running is the default, so both cases are starts:

  • a stopped container is started (start <svc>), the route is published once it has an address, and the plan never blocks on an address the service does not have yet;
  • a replacement already brings the service up, so no start is planned alongside replace-image;
  • state: stopped still wins outright over the default — nothing gets started behind its back.

converge now waits for the address after a start (a route is published to an address, and a just-started container has none), and the host simulator gives incus start the address a real one gets, so a resume is testable.

Tests

gofmt clean, go vet ./... clean, go test -race ./... green.

test asserts
TestStoppedServiceWithoutStateIsStartedNotBlocked no blockers, one start change, apply starts it and republishes the route
TestExplicitRunningIsNotBlockedByTheAddressItHasNotGotYet the resume dead-end: state: running on a stopped service plans a start with no blocker, and apply brings it back
TestADeclaredStopStillWinsOverTheDefault state: stopped still stops, and never plans a start

Also updated the two tests that asserted the old blocking behaviour, and README's state: note now says what the default does.

`state:` can stop a service (#101), but stopping it was still a one-way door and a
stopped container still blocked the whole fleet.

A stopped container has no IPv4 address, so the route check reports `no IPv4 address
(is it stopped?)` as a blocker, and a blocked plan is refused whole. Two cases hit
that:

  * resuming: `state: stopped` removed (or set to running) adds `start`, then falls
    through to the route check and blocks - so the deploy meant to bring the service
    back is refused before it runs;
  * anything stopped without a manifest saying so: a host reboot, a manual stop, or a
    manifest written before `state:` existed (the twenty case). Nothing is planned to
    start it, and every other service's deploy is refused too.

Running is the default, so both are starts: a stopped container is started, the route
is published once it has an address, and the plan never blocks on an address the
service does not have yet. A replacement still brings the service up by itself, so no
start is planned alongside it. `state: stopped` still wins outright over the default.

Adds the address wait after a start in converge (a route is published to an address,
and a container that has just started has none), and gives the host simulator's
`incus start` the address a real one gets, so a resume can be tested.

Tests: stopped with no state (start, no blocker, route republished), stopped with
`state: running` (the resume dead-end), and `state: stopped` still stopping without a
start. README's `state:` note now says what the default does.
@wmantly
wmantly merged commit f568213 into main Nov 13, 2026
2 checks passed
@wmantly
wmantly deleted the feat/start-stopped branch November 13, 2026 05:48
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