Skip to content

Commit 8d4c507

Browse files
committed
fix potential hang on containerd client.LoadContainer
Signed-off-by: lianghao208 <[email protected]>
1 parent 0b675de commit 8d4c507

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

container/containerd/factory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ func (f *containerdFactory) CanHandleAndAccept(name string) (bool, bool, error)
112112
id := ContainerNameToContainerdID(name)
113113
// If container and task lookup in containerd fails then we assume
114114
// that the container state is not known to containerd
115-
ctx := context.Background()
115+
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
116+
defer cancel()
116117
_, err := f.client.LoadContainer(ctx, id)
117118
if err != nil {
118119
return false, false, fmt.Errorf("failed to load container: %v", err)

0 commit comments

Comments
 (0)