Skip to content

Commit 3be680c

Browse files
committed
Ensure we dont fail if containers disappear (#3167)
Signed-off-by: apostasie <[email protected]>
1 parent 186ca39 commit 3be680c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/netutil/netutil.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,17 @@ func namespaceUsedNetworks(ctx context.Context, containers []containerd.Containe
8888
task, err := c.Task(ctx, nil)
8989
if err != nil {
9090
if errdefs.IsNotFound(err) {
91+
log.G(ctx).Debugf("task not found - likely container %q was removed", c.ID())
9192
continue
9293
}
9394
return nil, err
9495
}
9596
status, err := task.Status(ctx)
9697
if err != nil {
98+
if errdefs.IsNotFound(err) {
99+
log.G(ctx).Debugf("task not found - likely container %q was removed", c.ID())
100+
continue
101+
}
97102
return nil, err
98103
}
99104
switch status.Status {
@@ -103,6 +108,10 @@ func namespaceUsedNetworks(ctx context.Context, containers []containerd.Containe
103108
}
104109
l, err := c.Labels(ctx)
105110
if err != nil {
111+
if errdefs.IsNotFound(err) {
112+
log.G(ctx).Debugf("container %q is gone", c.ID())
113+
continue
114+
}
106115
return nil, err
107116
}
108117
networkJSON, ok := l[labels.Networks]

0 commit comments

Comments
 (0)