Skip to content

Commit

Permalink
Ensure we dont fail if containers disappear (#3167)
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Jul 6, 2024
1 parent 5811b94 commit fceea23
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/netutil/netutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,17 @@ func namespaceUsedNetworks(ctx context.Context, containers []containerd.Containe
task, err := c.Task(ctx, nil)
if err != nil {
if errdefs.IsNotFound(err) {
log.G(ctx).Debugf("task not found - likely container %q was removed", c.ID())
continue
}
return nil, err
}
status, err := task.Status(ctx)
if err != nil {
if errdefs.IsNotFound(err) {
log.G(ctx).Debugf("task not found - likely container %q was removed", c.ID())
continue
}
return nil, err
}
switch status.Status {
Expand All @@ -103,6 +108,10 @@ func namespaceUsedNetworks(ctx context.Context, containers []containerd.Containe
}
l, err := c.Labels(ctx)
if err != nil {
if errdefs.IsNotFound(err) {
log.G(ctx).Debugf("container %q is gone", c.ID())
continue
}
return nil, err
}
networkJSON, ok := l[labels.Networks]
Expand Down

0 comments on commit fceea23

Please sign in to comment.