Skip to content

Commit

Permalink
Do not hard error if containers are gone
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  • Loading branch information
apostasie committed Jul 5, 2024
1 parent bc24aa9 commit 156b5fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cmd/container/run_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package container
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -307,6 +308,12 @@ func generateMountOpts(ctx context.Context, client *containerd.Client, ensuredIm
for _, c := range containers {
ls, err := c.Labels(ctx)
if err != nil {
// Containerd note: there is no guarantee that the containers we got from the list still exist at this point
// If that is the case, just ignore and move on
if errors.Is(err, errdefs.ErrNotFound) {
log.G(ctx).Debugf("container %q is gone - ignoring", c.ID())
continue
}
return nil, nil, nil, err
}
_, idMatch := vfSet[c.ID()]
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/volume/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func usedVolumes(ctx context.Context, containers []containerd.Container) (map[st
// Containerd note: there is no guarantee that the containers we got from the list still exist at this point
// If that is the case, just ignore and move on
if errors.Is(err, errdefs.ErrNotFound) {
log.G(ctx).Debugf("container %q is gone - ignoring", c.ID())
continue
}
return nil, err
Expand Down

0 comments on commit 156b5fd

Please sign in to comment.