mirror of https://github.com/containers/podman.git
				
				
				
			Remove another race condition when mounting containers or images
Fixes: https://github.com/containers/podman/issues/23507 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
		
							parent
							
								
									7e469996b1
								
							
						
					
					
						commit
						abd586cb1c
					
				|  | @ -34,6 +34,7 @@ import ( | ||||||
| 	"github.com/containers/podman/v5/pkg/specgenutil" | 	"github.com/containers/podman/v5/pkg/specgenutil" | ||||||
| 	"github.com/containers/podman/v5/pkg/util" | 	"github.com/containers/podman/v5/pkg/util" | ||||||
| 	"github.com/containers/storage" | 	"github.com/containers/storage" | ||||||
|  | 	"github.com/containers/storage/types" | ||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -1367,6 +1368,11 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin | ||||||
| 	for _, ctr := range containers { | 	for _, ctr := range containers { | ||||||
| 		report := entities.ContainerMountReport{Id: ctr.ID()} | 		report := entities.ContainerMountReport{Id: ctr.ID()} | ||||||
| 		report.Path, report.Err = ctr.Mount() | 		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) | 		reports = append(reports, &report) | ||||||
| 	} | 	} | ||||||
| 	if len(reports) > 0 { | 	if len(reports) > 0 { | ||||||
|  | @ -1381,6 +1387,9 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin | ||||||
| 	for _, sctr := range storageCtrs { | 	for _, sctr := range storageCtrs { | ||||||
| 		mounted, path, err := ic.Libpod.IsStorageContainerMounted(sctr.ID) | 		mounted, path, err := ic.Libpod.IsStorageContainerMounted(sctr.ID) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | 			if errors.Is(err, types.ErrContainerUnknown) { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -1405,6 +1414,10 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin | ||||||
| 	for _, ctr := range containers { | 	for _, ctr := range containers { | ||||||
| 		mounted, path, err := ctr.Mounted() | 		mounted, path, err := ctr.Mounted() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | 			if errors.Is(err, define.ErrNoSuchCtr) || | ||||||
|  | 				errors.Is(err, define.ErrCtrRemoved) { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -35,6 +35,7 @@ import ( | ||||||
| 	"github.com/containers/podman/v5/pkg/errorhandling" | 	"github.com/containers/podman/v5/pkg/errorhandling" | ||||||
| 	"github.com/containers/podman/v5/pkg/rootless" | 	"github.com/containers/podman/v5/pkg/rootless" | ||||||
| 	"github.com/containers/storage" | 	"github.com/containers/storage" | ||||||
|  | 	"github.com/containers/storage/types" | ||||||
| 	"github.com/opencontainers/go-digest" | 	"github.com/opencontainers/go-digest" | ||||||
| 	imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" | 	imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" | ||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
|  | @ -181,6 +182,9 @@ func (ir *ImageEngine) Mount(ctx context.Context, nameOrIDs []string, opts entit | ||||||
| 			// We're only looking for mounted images.
 | 			// We're only looking for mounted images.
 | ||||||
| 			mountPoint, err = i.Mountpoint() | 			mountPoint, err = i.Mountpoint() | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
|  | 				if errors.Is(err, types.ErrImageUnknown) { | ||||||
|  | 					continue | ||||||
|  | 				} | ||||||
| 				return nil, err | 				return nil, err | ||||||
| 			} | 			} | ||||||
| 			// Not mounted, so skip.
 | 			// Not mounted, so skip.
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue