Repository navigation
feat: restart sockets around their running service - #53
Conversation
Adding or changing a socket whose service is running no longer fails apply: core-ops stops the service, starts or restarts the socket once, and starts the service again. Plan shows it as activated_service on the socket's entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pport support-template-quadlets landed in v3.1.0. Record how the restart bracket meets its activation guard (design D9, task 3.6), derive `activated_service` after the guard, and list the field in operator-output "Plan JSON document" now that the parallel change no longer owns that requirement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A created or changed .socket whose service runs was started or restarted
directly, so systemd refused ("Socket service ... already active") and
apply failed halfway with the old listener in place.
The planner now starts or restarts each created or changed socket exactly
once. When the service it activates (resolved like the verifier, from
Service= across the base unit and drop-ins) was active, the plan stops it
before the socket action and starts it again once after all diff actions;
an inactive service is left alone. Container restarts of that service move
behind the socket restart, config-driven restarts deduplicate against it,
and a changed socket no longer starts its same-stem service unconditionally.
Observation now also queries each desired socket's service, even when
unmanaged.
plan shows the bracket as `activated_service` on the socket entry and a
"service <unit> will be stopped for the socket change and started again"
line; apply reports the stop and start under the socket entry.
Covered by three accepted VM scenarios (passed on ulthar), archives the
socket-restart-sequence change and prepares release 3.2.0. Records the
phantom container restart seen in those runs and the design's follow-ups
in docs/follow-ups.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fcde30923
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
An Accept=yes socket starts one service instance per connection and activates no shared service, but the restart sequence resolved it to <stem>.service like any socket. A changed echo.socket therefore stopped and started an unrelated active echo.service, and observation queried it. Resolve Accept= like Service= (last assignment across the base unit and desired drop-ins, empty resets to no). An accepting socket is still started or restarted once, with no stop, start or observation of a service on its behalf. Specified as quadlet-artifacts "Accepting sockets activate no shared service"; recorded as design D10 and task 3.7 of the archived socket-restart-sequence change, which has not shipped yet. Addresses the Codex review finding on PR #53. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c10ac653f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A template socket is never started, but the restart sequence still resolved its Service=. With `Service=shared.service` on app@.socket, a drop-in change under app@.socket.d/ stopped and started an active shared.service; the activation guard then dropped the app@.socket restart (a template target) but kept the stop and start (a non-template target), bouncing the service without touching any listener. Template sockets are now skipped before services are resolved (design D9 revised, task 3.8, new scenario "Template socket names a shared service"). Also adds the accepted regression scenario for accepting sockets (task 6.5): accept-socket-history changes an Accept=yes echo.socket next to a running echo.service, then moves Accept=yes into a drop-in, and checks that echo.service keeps its InvocationID. It passes on the VM and fails with a core-ops built before the Accept= fix. Addresses the two Codex review findings on 5c10ac6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d9b52215d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
systemd accepts `Service = x.service` and `Accept = yes`, but the socket directive lookup only matched `Service=` and `Accept=` verbatim. A spaced Service= therefore resolved to <stem>.service: the planner bracketed the wrong service (or none) and systemd refused the socket start because the real service ran; a spaced Accept= was ignored and an unrelated service was bracketed. Assignments are now split at `=` and the key trimmed (task 3.9, scenarios "Whitespace around ..."). Adds accepted VM regression coverage for this and for the template socket fix in 9d9b522 (task 6.6): socket-shared-service-history changes a template socket's drop-in while shared.service runs (invocation must be kept), then adds web.socket with `Service = shared.service` (apply must converge). accept-v3 now spells `Accept = yes`. Both scenarios pass on the VM; a core-ops built from 5c10ac6 fails exactly those assertions, with systemd logging "Socket service shared.service already active, refusing". Addresses the two Codex review findings on 9d9b522. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Archives OpenSpec change socket-restart-sequence and releases as 3.2.0 (
minor). Fixes field-report point 4: aListenStream=change ontraefik.socketwhiletraefik.serviceran made systemd refuse the socket restart, so apply failed halfway and the old listener stayed.Service=across base unit and desired drop-ins, else<stem>.service). If it was active, the plan stops it before the socket action and starts it again once after all diff actions; an inactive or failed service is left alone, so socket activation still starts it on demand.RestartUnit), config-driven restarts skip a service the sequence already starts, and a changed socket no longer starts its same-stem service unconditionally (still done for created sockets, once).planshows the stop/start on the socket's entry: JSONactivated_service: {unit, disposition: "stop_start"}and the human lineservice <unit> will be stopped for the socket change and started again. Apply reports the steps under that entry, and a failed stop/start names the service, e.g.(service traefik.service).Verification
cargo build --locked,cargo test(65 lib + 579),cargo clippy --all-targets -- -D warnings,openspec validate --all --strict,core-ops-release validate --base-ref origin/masterall pass.accepted-socket-restart-active-service,accepted-socket-restart-inactive-service,accepted-socket-added-running-service, with thesocket-restart-historyfixture.homelab-e2eapproval.Notes
planstep: apply output does not render it, per the spec (as with template instance lines). The task wording was corrected before archiving.docs/follow-ups.md: a socket change still classifies the socket-activated container asrestart("dependency changed"), so plan and apply reportcontainer/frontend.container restartedand1 restartalthough the executable plan never restarts it. The VM runs show it for both active and inactive services. This was already there (reconciliation D22 / operator-output D17); the follow-up entry proposes a fix. Also recorded: the activation race,Service=retargeted in the same change, and removed socket drop-ins (design D7).🤖 Generated with Claude Code