Skip to content

Commit

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

[release-1.5] 🌱 CAPD: fix multi error handling in RunContainer
  • Loading branch information
k8s-ci-robot authored Aug 18, 2023
2 parents a8e401f + a241538 commit 0c15a78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/infrastructure/container/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/go-connections/nat"
"github.com/pkg/errors"
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/utils/pointer"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -508,8 +509,8 @@ func (d *dockerRuntime) RunContainer(ctx context.Context, runConfig *RunContaine
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)
if reterr := d.dockerClient.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true}); reterr != nil {
return kerrors.NewAggregate([]error{err, errors.Wrapf(reterr, "error deleting container")})
}
return err
}
Expand Down

0 comments on commit 0c15a78

Please sign in to comment.