Repository navigation
Conversation
kvinwang
force-pushed
the
fix/app-compose-agent-restart
branch
from
December 1, 2026 03:01
8c89af2 to
6bc4b95
Compare
Requires=dstack-guest-agent.service on app-compose propagates restarts, so every agent restart (crash, watchdog kill, manual restart) ran app-compose's ExecStop and stopped all app containers. Add dstack-guest-agent-wait.service, a oneshot that polls until the agent is active, giving up once it is failed or after 300s. app-compose, docker and containerd Require= it instead of the agent. It has no Restart= and only Wants= the agent, so agent restarts stop there. Like network-online.target, it marks that the agent came up during boot. Polling is needed because After= is satisfied by the agent's first failed attempt even when Restart= brings it up later. The poll moves out of docker's drop-in. containerd now waits too: it starts restart-policy containers of the nerdctl-compose runner before app-compose runs, and nothing held it back before. Signed-off-by: Kevin Wang <[email protected]>
kvinwang
force-pushed
the
fix/app-compose-agent-restart
branch
from
December 1, 2026 03:21
6bc4b95 to
5bc8928
Compare
This branch has not been deployed
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.
Problem
Since #1324,
app-compose.servicehasRequires=dstack-guest-agent.service.Requires=also propagates restarts: when the agent dies andRestart=alwaysbrings it back (crash or watchdog kill), systemd restartsapp-compose.servicetoo. ItsExecStoprunscompose stop, so every agent restart stops all app containers and brings them back withcompose up(followed by an image/volume prune). A manualsystemctl restart dstack-guest-agentdoes the same.#1625 fixed the watchdog probe race that was killing the agent on 0.6.5 guests. This PR removes the coupling, so an agent restart for any other reason no longer takes the app down with it.
Affected: v0.5.12+ and v0.6.0+.
Fix
Add
dstack-guest-agent-wait.service, a oneshot that polls until the agent is active and gives up once it isfailedor after 300s (reported throughOnFailure=).app-compose, docker and containerdRequire=it instead of the agent. It onlyWants=the agent and has noRestart=, so agent restarts stop there. Likenetwork-online.target, it marks that the agent came up during boot, not that it is up now.After=is satisfied by the agent's first failed attempt even whenRestart=brings it up later.nerdctl-composerunner's restart-policy containers beforeapp-composeruns, and nothing held it back before.Alternatives that do not work:
RestartMode=directon the agent stops the propagation on systemd 257 but not on 255, and does not cover a manual restart.Wants=/Before=it is reached after the agent's first failed attempt; withRequires=on the agent it propagates restarts again.Verification
Mock units on systemd 255 (Ubuntu): agent
Type=notify,Restart=always; wait unit as in this PR; mock containerd, docker and app wired as in this PR, each logging whether the agent was active when it started.systemctl kill -s KILLsystemctl restartagentOnFailure=firesOnFailure=firesWith the old
Requires=, the kill case stops and restarts the app on both systemd 255 and 257 (debian:trixie).I have not tested this on a real CVM image.