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

Commit 40ba102

Browse files
committed
Rename waitForContainerToStart to ensureContainerStarted
This better reflects the function's behavior. Signed-off-by: Jacob Howard <[email protected]>
1 parent 5871b6f commit 40ba102

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/standalone/containers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ func determineBridgeGatewayIP(ctx context.Context, dockerClient client.NetworkAP
173173
return "", nil
174174
}
175175

176-
// waitForContainerToStart waits for a container to start.
177-
func waitForContainerToStart(ctx context.Context, dockerClient client.ContainerAPIClient, containerID string) error {
176+
// ensureContainerStarted ensures that a container has started. It may be called
177+
// concurrently, taking advantage of the fact that ContainerStart is idempotent.
178+
func ensureContainerStarted(ctx context.Context, dockerClient client.ContainerAPIClient, containerID string) error {
178179
for i := 10; i > 0; i-- {
179180
err := dockerClient.ContainerStart(ctx, containerID, container.StartOptions{})
180181
if err == nil {
@@ -282,7 +283,7 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
282283

283284
// Start the container.
284285
printer.Printf("Starting model runner container %s...\n", controllerContainerName)
285-
if err := waitForContainerToStart(ctx, dockerClient, controllerContainerName); err != nil {
286+
if err := ensureContainerStarted(ctx, dockerClient, controllerContainerName); err != nil {
286287
if created {
287288
_ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true})
288289
}

0 commit comments

Comments
 (0)