-
Notifications
You must be signed in to change notification settings - Fork 16
Clean up standalone container startup using Moby idioms #107
Conversation
Signed-off-by: Jacob Howard <[email protected]>
The start endpoint should be idempotent when trying to start a container that is already started (see [Daemon.containerStart][1], so we can take advantage of that. Once we either created the container, or received a "conflict" (name already in use), we can try starting the container. As there's a time window between a name being reserved and the container to exist (which may produce a 404 during that time window), we ignore "not found" errors, and retry the start. [1]: https://github.com/moby/moby/blob/5318877858c9fc94b5cccc3cf1a75d4ec46951b8/daemon/start.go#L76-L93 Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Jacob Howard <[email protected]>
Signed-off-by: Jacob Howard <[email protected]>
This better reflects the function's behavior. Signed-off-by: Jacob Howard <[email protected]>
p1-0tr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (but haven't tested 😅), thanks!
| if err := waitForContainerToStart(ctx, dockerClient, controllerContainerName); err != nil { | ||
| _ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true}) | ||
| if created { | ||
| _ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker; mostly thinking out loud if there would be cases where the remove would fail, and cause issues later (so if it would make sense to print a warning and continue).
| // For some reason, this error case can also manifest as an EOF on the | ||
| // request (I'm not sure where this arises in the Moby server), so we'll | ||
| // let that pass silently too. | ||
| if !(errdefs.IsNotFound(err) || errors.Is(err, io.EOF)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still interested in this situation; something we should look into to see what's causing this (as it seems unexpected).
This PR supersedes #98 and #99. It folds in a few extra changes and rebases on
main.