Skip to content

Commit

Permalink
Merge pull request docker#5043 from vvoland/wait-cancel-noerror
Browse files Browse the repository at this point in the history
waitExitOrRemoved: Handle context cancellation
  • Loading branch information
vvoland authored Apr 29, 2024
2 parents 67aa271 + 840016e commit e81b835
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 e81b835

Please sign in to comment.