Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions pkg/standalone/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,31 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
}

// Create the container. If we detect that a concurrent installation is in
// progress, then we wait for whichever install process creates the
// container first and then wait for its container to be ready.
// progress (as indicated by a conflicting container name (which should have
// been detected just before installation)), then we'll allow the error to
// pass silently and simply work in conjunction with any concurrent
// installers to start the container.
resp, err := dockerClient.ContainerCreate(ctx, config, hostConfig, nil, nil, controllerContainerName)
if !errdefs.IsConflict(err) {
if err != nil && !errdefs.IsConflict(err) {
return fmt.Errorf("failed to create container %s: %w", controllerContainerName, err)
}
created := err == nil

// Start the container.
printer.Printf("Starting model runner container %s...\n", controllerContainerName)
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).

}
return fmt.Errorf("failed to start container %s: %w", controllerContainerName, err)
}

// Copy Docker config file if it exists
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID, engineKind); err != nil {
// Log warning but continue - don't fail container creation
printer.Printf("Warning: failed to copy Docker config: %v\n", err)
// Copy Docker config file if it exists and we're the container creator.
if created {
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID, engineKind); err != nil {
// Log warning but continue - don't fail container creation
printer.Printf("Warning: failed to copy Docker config: %v\n", err)
}
}
return nil
}
Expand Down