Skip to content

Commit

Permalink
Merge pull request #3194 from apostasie/dev-3167
Browse files Browse the repository at this point in the history
Network prune should not fail if containers vanish
  • Loading branch information
AkihiroSuda authored Jul 6, 2024
2 parents 5811b94 + fceea23 commit 95a5fca
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 95a5fca

Please sign in to comment.