Skip to content

Commit

Permalink
Merge pull request #9130 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…9125-to-release-1.5

[release-1.5] 🐛 CAPD: delete container after failed start to work around port allocation issues
  • Loading branch information
k8s-ci-robot authored Aug 18, 2023
2 parents 1c8860d + 3b240eb commit a8e401f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/infrastructure/container/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,13 @@ func (d *dockerRuntime) RunContainer(ctx context.Context, runConfig *RunContaine

// Actually start the container
if err := d.dockerClient.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
return errors.Wrapf(err, "error starting container %q", runConfig.Name)
err := errors.Wrapf(err, "error starting container %q", runConfig.Name)
// Delete the container and retry later on. This helps getting around the race
// condition where of hitting "port is already allocated" issues.
if innerErr := d.dockerClient.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true}); innerErr != nil {
return errors.Wrapf(innerErr, "error removing container after failed start: %s", err)
}
return err
}

if output != nil {
Expand Down

0 comments on commit a8e401f

Please sign in to comment.