Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Conversation

@xenoscopic
Copy link
Contributor

This PR supersedes #98 and #99. It folds in a few extra changes and rebases on main.

xenoscopic and others added 5 commits June 26, 2025 16:41
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]>
This better reflects the function's behavior.

Signed-off-by: Jacob Howard <[email protected]>
Copy link

@p1-0tr p1-0tr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a 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})
Copy link
Member

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).

Comment on lines +197 to +200
// 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)) {
Copy link
Member

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).

@xenoscopic xenoscopic merged commit d2a2a56 into main Jun 27, 2025
6 checks passed
@xenoscopic xenoscopic deleted the container-start-cleanup-rebase branch June 27, 2025 15:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants