Skip to content

Commit 840016e

Browse files
committed
waitExitOrRemoved: Handle context cancellation
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent 9714adc commit 840016e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cli/command/container/utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package container
22

33
import (
44
"context"
5+
"errors"
56
"strconv"
67

78
"github.com/docker/docker/api/types"
@@ -36,6 +37,8 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
3637
statusC := make(chan int)
3738
go func() {
3839
select {
40+
case <-ctx.Done():
41+
return
3942
case result := <-resultC:
4043
if result.Error != nil {
4144
logrus.Errorf("Error waiting for container: %v", result.Error.Message)
@@ -44,6 +47,9 @@ func waitExitOrRemoved(ctx context.Context, apiClient client.APIClient, containe
4447
statusC <- int(result.StatusCode)
4548
}
4649
case err := <-errC:
50+
if errors.Is(err, context.Canceled) {
51+
return
52+
}
4753
logrus.Errorf("error waiting for container: %v", err)
4854
statusC <- 125
4955
}

0 commit comments

Comments
 (0)