mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #15197 from vrothberg/fix-15006
podman rmi: improve error message for build containers
This commit is contained in:
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
||||
github.com/containernetworking/cni v1.1.2
|
||||
github.com/containernetworking/plugins v1.1.1
|
||||
github.com/containers/buildah v1.26.1-0.20220716095526-d31d27c357ab
|
||||
github.com/containers/common v0.49.1-0.20220729221035-246800047d46
|
||||
github.com/containers/common v0.49.2-0.20220804143628-dc97077782d5
|
||||
github.com/containers/conmon v2.0.20+incompatible
|
||||
github.com/containers/image/v5 v5.22.0
|
||||
github.com/containers/ocicrypt v1.1.5
|
||||
|
4
go.sum
4
go.sum
@ -395,8 +395,8 @@ github.com/containernetworking/plugins v1.1.1/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19
|
||||
github.com/containers/buildah v1.26.1-0.20220716095526-d31d27c357ab h1:NeI0DOkTf3Tn4OpdjMhMubAfTPs2oCO5jUY5wnpv4qk=
|
||||
github.com/containers/buildah v1.26.1-0.20220716095526-d31d27c357ab/go.mod h1:iVtQtU6a+pbETBqIzg0oAWW3gTR1ItrAihJpLFFppmA=
|
||||
github.com/containers/common v0.48.1-0.20220715075726-2ac10faca05a/go.mod h1:1dA7JPGoSi83kjf5H4NIrGANyLOULyvFqV1bwvYFEek=
|
||||
github.com/containers/common v0.49.1-0.20220729221035-246800047d46 h1:BNNV+JlPYSmaa9rTapL9kh2JZrg7hmWwi/VrIY/KH1E=
|
||||
github.com/containers/common v0.49.1-0.20220729221035-246800047d46/go.mod h1:ueM5hT0itKqCQvVJDs+EtjornAQtrHYxQJzP2gxeGIg=
|
||||
github.com/containers/common v0.49.2-0.20220804143628-dc97077782d5 h1:bOdbfjiOvj5n51dyeo8LF3qAtvaiflS13q70Cx4NA40=
|
||||
github.com/containers/common v0.49.2-0.20220804143628-dc97077782d5/go.mod h1:ueM5hT0itKqCQvVJDs+EtjornAQtrHYxQJzP2gxeGIg=
|
||||
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
||||
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
|
||||
github.com/containers/image/v5 v5.21.2-0.20220712113758-29aec5f7bbbf/go.mod h1:0+N0ZM9mgMmoZZc6uNcgnEsbX85Ne7b29cIW5lqWwVU=
|
||||
|
@ -259,8 +259,8 @@ Labels.created_at | 20[0-9-]\\\+T[0-9:]\\\+Z
|
||||
|
||||
run_podman 2 rmi -a
|
||||
is "$output" "Error: 2 errors occurred:
|
||||
.** image used by .*: image is in use by a container
|
||||
.** image used by .*: image is in use by a container"
|
||||
.** image used by .*: image is in use by a container: consider listing external containers and force-removing image
|
||||
.** image used by .*: image is in use by a container: consider listing external containers and force-removing image"
|
||||
|
||||
run_podman rmi -af
|
||||
is "$output" "Untagged: $IMAGE
|
||||
@ -292,7 +292,7 @@ Deleted: $pauseID" "infra images gets removed as well"
|
||||
pauseID=$output
|
||||
|
||||
run_podman 2 rmi $pauseImage
|
||||
is "$output" "Error: image used by .* image is in use by a container"
|
||||
is "$output" "Error: image used by .* image is in use by a container: consider listing external containers and force-removing image"
|
||||
|
||||
run_podman rmi -f $pauseImage
|
||||
is "$output" "Untagged: $pauseImage
|
||||
|
9
vendor/github.com/containers/common/libimage/image.go
generated
vendored
9
vendor/github.com/containers/common/libimage/image.go
generated
vendored
@ -470,6 +470,9 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
}
|
||||
|
||||
if _, err := i.runtime.store.DeleteImage(i.ID(), true); handleError(err) != nil {
|
||||
if errors.Is(err, storage.ErrImageUsedByContainer) {
|
||||
err = fmt.Errorf("%w: consider listing external containers and force-removing image", err)
|
||||
}
|
||||
return processedIDs, err
|
||||
}
|
||||
report.Untagged = append(report.Untagged, i.Names()...)
|
||||
@ -478,6 +481,11 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
report.Removed = true
|
||||
}
|
||||
|
||||
// Do not delete any parents if NoPrune is true
|
||||
if options.NoPrune {
|
||||
return processedIDs, nil
|
||||
}
|
||||
|
||||
// Check if can remove the parent image.
|
||||
if parent == nil {
|
||||
return processedIDs, nil
|
||||
@ -495,7 +503,6 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
if !danglingParent {
|
||||
return processedIDs, nil
|
||||
}
|
||||
|
||||
// Recurse into removing the parent.
|
||||
return parent.removeRecursive(ctx, rmMap, processedIDs, "", options)
|
||||
}
|
||||
|
3
vendor/github.com/containers/common/libimage/runtime.go
generated
vendored
3
vendor/github.com/containers/common/libimage/runtime.go
generated
vendored
@ -608,6 +608,8 @@ type RemoveImagesOptions struct {
|
||||
// much space was freed. However, computing the size of an image is
|
||||
// comparatively expensive, so it is made optional.
|
||||
WithSize bool
|
||||
// NoPrune will not remove dangling images
|
||||
NoPrune bool
|
||||
}
|
||||
|
||||
// RemoveImages removes images specified by names. If no names are specified,
|
||||
@ -653,7 +655,6 @@ func (r *Runtime) RemoveImages(ctx context.Context, names []string, options *Rem
|
||||
toDelete := []string{}
|
||||
// Look up images in the local containers storage and fill out
|
||||
// toDelete and the deleteMap.
|
||||
|
||||
switch {
|
||||
case len(names) > 0:
|
||||
// prepare lookupOptions
|
||||
|
2
vendor/github.com/containers/common/version/version.go
generated
vendored
2
vendor/github.com/containers/common/version/version.go
generated
vendored
@ -1,4 +1,4 @@
|
||||
package version
|
||||
|
||||
// Version is the version of the build.
|
||||
const Version = "0.49.1-dev"
|
||||
const Version = "0.49.2-dev"
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -114,7 +114,7 @@ github.com/containers/buildah/pkg/rusage
|
||||
github.com/containers/buildah/pkg/sshagent
|
||||
github.com/containers/buildah/pkg/util
|
||||
github.com/containers/buildah/util
|
||||
# github.com/containers/common v0.49.1-0.20220729221035-246800047d46
|
||||
# github.com/containers/common v0.49.2-0.20220804143628-dc97077782d5
|
||||
## explicit
|
||||
github.com/containers/common/libimage
|
||||
github.com/containers/common/libimage/define
|
||||
|
Reference in New Issue
Block a user