Skip to content

Commit

Permalink
Merge pull request #3168 from apostasie/dev-race-fallout
Browse files Browse the repository at this point in the history
Fix wrong assumption about container availability
  • Loading branch information
AkihiroSuda authored Jul 4, 2024
2 parents 21dbf14 + 150f9cb commit c765e4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cmd/volume/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"

"github.com/containerd/containerd"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/log"
"github.com/containerd/nerdctl/v2/pkg/api/types"
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
Expand Down Expand Up @@ -75,6 +76,11 @@ func usedVolumes(ctx context.Context, containers []containerd.Container) (map[st
for _, c := range containers {
l, 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) {
continue
}
return nil, err
}
mountsJSON, ok := l[labels.Mounts]
Expand Down

0 comments on commit c765e4a

Please sign in to comment.