Skip to content

Commit

Permalink
Merge pull request #23512 from rhatdan/mount
Browse files Browse the repository at this point in the history
Remove another race condition when mounting containers or images
  • Loading branch information
openshift-merge-bot[bot] authored Aug 6, 2024
2 parents 69862b7 + abd586c commit 3275fd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/containers/podman/v5/pkg/specgenutil"
"github.com/containers/podman/v5/pkg/util"
"github.com/containers/storage"
"github.com/containers/storage/types"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -1367,6 +1368,11 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
for _, ctr := range containers {
report := entities.ContainerMountReport{Id: ctr.ID()}
report.Path, report.Err = ctr.Mount()
if options.All &&
(errors.Is(report.Err, define.ErrNoSuchCtr) ||
errors.Is(report.Err, define.ErrCtrRemoved)) {
continue
}
reports = append(reports, &report)
}
if len(reports) > 0 {
Expand All @@ -1381,6 +1387,9 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
for _, sctr := range storageCtrs {
mounted, path, err := ic.Libpod.IsStorageContainerMounted(sctr.ID)
if err != nil {
if errors.Is(err, types.ErrContainerUnknown) {
continue
}
return nil, err
}

Expand All @@ -1405,6 +1414,10 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
for _, ctr := range containers {
mounted, path, err := ctr.Mounted()
if err != nil {
if errors.Is(err, define.ErrNoSuchCtr) ||
errors.Is(err, define.ErrCtrRemoved) {
continue
}
return nil, err
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/domain/infra/abi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/containers/podman/v5/pkg/errorhandling"
"github.com/containers/podman/v5/pkg/rootless"
"github.com/containers/storage"
"github.com/containers/storage/types"
"github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -181,6 +182,9 @@ func (ir *ImageEngine) Mount(ctx context.Context, nameOrIDs []string, opts entit
// We're only looking for mounted images.
mountPoint, err = i.Mountpoint()
if err != nil {
if errors.Is(err, types.ErrImageUnknown) {
continue
}
return nil, err
}
// Not mounted, so skip.
Expand Down

0 comments on commit 3275fd2

Please sign in to comment.