Repository navigation
fix(docker): start recreated container after update unless deliberately stopped or lazy - #620
Open
madejackson wants to merge 2 commits into
Open
madejackson wants to merge 2 commits into
madejackson wants to merge 2 commits into
Conversation
…ly stopped or lazy EditContainer decided whether to start the recreated container solely from the old container's State.Running, but the old container has already been stopped by this same function at that point, so State.Running is false for every container. Running services were recreated and then left down after an auto-update. Decide from stable intent instead: lazy containers (cosmos-lazy) are left stopped (reaper-managed, wake on demand); explicitly stopped containers stay stopped; everything else — including no/unknown State — is started.
…ly stopped or lazy EditContainer decided whether to start the recreated container solely from the old container's State.Running, but the old container has already been stopped by this same function at that point, so State.Running is false for every container. Running services were recreated and then left down after an auto-update. Decide from stable intent instead: lazy containers (cosmos-lazy) are left stopped (reaper-managed, wake on demand); explicitly stopped containers stay stopped; everything else — including no/unknown State — is started.
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.
I had it happen multiple times now that container did not got restarted after auto-update. I suspect this is because of the new lazytainer handling and plurality agrees with me. This PR changes the detection logic so it should always restart a container when it was not explicitly stopped.
AI Summary:
What
An auto-update (or any container edit) could leave a running container recreated but not started — stuck in
createduntil someone starts it manually. The container was updated, but the service stayed down.Root cause
EditContainerdecides whether to start the recreated container after it has already stopped the old one, and it made that decision from the old container'sState.Running:At that point the old container was just stopped by this same function (
ContainerStopruns right before this block), soState.Runningisfalsefor every container — including ones that were running a moment earlier. The code therefore always took the "leave stopped" branch, and the freshly created replacement was never started. The check effectively inverted the caller's intent for every update/auto-update.(The previous
State != nilguard also had no protective value here:ContainerInspectreturns an error for a missing container andEditContainerreturns early on it, sooldContainercan't be nil at the decision point.)Fix
Decide from stable, explicit intent instead of the old container's transient (and by-then-already-stopped) runtime state — i.e. invert the default:
cosmos-lazy=true): never auto-start after recreate — they are managed by the reaper and wake on demand. (Preserves the lazy feature.)State != nil && !Running= the user stopped it, or it never ran): keep stopped after recreate. (Preserves "a stopped container stays stopped".)Why this is safe
IsLazyLabelshelper already used inapi_blueprint.goandapi_updateContainer.go.Test plan
go build ./...passes