Skip to content

Commit

Permalink
Merge pull request #5044 from vvoland/wait-cancel-noerror
Browse files Browse the repository at this point in the history
[26.1 backport] waitExitOrRemoved: Handle context cancellation
  • Loading branch information
vvoland authored Apr 29, 2024
2 parents 9714adc + 840016e commit 1e6db5d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/command/container/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package container

import (
"context"
"errors"
"strconv"

"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -36,6 +37,8 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
statusC := make(chan int)
go func() {
select {
case <-ctx.Done():
return
case result := <-resultC:
if result.Error != nil {
logrus.Errorf("Error waiting for container: %v", result.Error.Message)
Expand All @@ -44,6 +47,9 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
statusC <- int(result.StatusCode)
}
case err := <-errC:
if errors.Is(err, context.Canceled) {
return
}
logrus.Errorf("error waiting for container: %v", err)
statusC <- 125
}
Expand Down

0 comments on commit 1e6db5d

Please sign in to comment.