mirror of https://github.com/containers/podman.git
Merge pull request #15197 from vrothberg/fix-15006
podman rmi: improve error message for build containers
This commit is contained in:
commit
e9f1eb28c4
2
go.mod
2
go.mod
|
@ -12,7 +12,7 @@ require (
|
||||||
github.com/containernetworking/cni v1.1.2
|
github.com/containernetworking/cni v1.1.2
|
||||||
github.com/containernetworking/plugins v1.1.1
|
github.com/containernetworking/plugins v1.1.1
|
||||||
github.com/containers/buildah v1.26.1-0.20220716095526-d31d27c357ab
|
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/conmon v2.0.20+incompatible
|
||||||
github.com/containers/image/v5 v5.22.0
|
github.com/containers/image/v5 v5.22.0
|
||||||
github.com/containers/ocicrypt v1.1.5
|
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 h1:NeI0DOkTf3Tn4OpdjMhMubAfTPs2oCO5jUY5wnpv4qk=
|
||||||
github.com/containers/buildah v1.26.1-0.20220716095526-d31d27c357ab/go.mod h1:iVtQtU6a+pbETBqIzg0oAWW3gTR1ItrAihJpLFFppmA=
|
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.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.2-0.20220804143628-dc97077782d5 h1:bOdbfjiOvj5n51dyeo8LF3qAtvaiflS13q70Cx4NA40=
|
||||||
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/go.mod h1:ueM5hT0itKqCQvVJDs+EtjornAQtrHYxQJzP2gxeGIg=
|
||||||
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
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/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=
|
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
|
run_podman 2 rmi -a
|
||||||
is "$output" "Error: 2 errors occurred:
|
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: consider listing external containers and force-removing image
|
||||||
.** 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"
|
||||||
|
|
||||||
run_podman rmi -af
|
run_podman rmi -af
|
||||||
is "$output" "Untagged: $IMAGE
|
is "$output" "Untagged: $IMAGE
|
||||||
|
@ -292,7 +292,7 @@ Deleted: $pauseID" "infra images gets removed as well"
|
||||||
pauseID=$output
|
pauseID=$output
|
||||||
|
|
||||||
run_podman 2 rmi $pauseImage
|
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
|
run_podman rmi -f $pauseImage
|
||||||
is "$output" "Untagged: $pauseImage
|
is "$output" "Untagged: $pauseImage
|
||||||
|
|
|
@ -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 _, 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
|
return processedIDs, err
|
||||||
}
|
}
|
||||||
report.Untagged = append(report.Untagged, i.Names()...)
|
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
|
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.
|
// Check if can remove the parent image.
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
return processedIDs, nil
|
return processedIDs, nil
|
||||||
|
@ -495,7 +503,6 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||||
if !danglingParent {
|
if !danglingParent {
|
||||||
return processedIDs, nil
|
return processedIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurse into removing the parent.
|
// Recurse into removing the parent.
|
||||||
return parent.removeRecursive(ctx, rmMap, processedIDs, "", options)
|
return parent.removeRecursive(ctx, rmMap, processedIDs, "", options)
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,6 +608,8 @@ type RemoveImagesOptions struct {
|
||||||
// much space was freed. However, computing the size of an image is
|
// much space was freed. However, computing the size of an image is
|
||||||
// comparatively expensive, so it is made optional.
|
// comparatively expensive, so it is made optional.
|
||||||
WithSize bool
|
WithSize bool
|
||||||
|
// NoPrune will not remove dangling images
|
||||||
|
NoPrune bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveImages removes images specified by names. If no names are specified,
|
// 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{}
|
toDelete := []string{}
|
||||||
// Look up images in the local containers storage and fill out
|
// Look up images in the local containers storage and fill out
|
||||||
// toDelete and the deleteMap.
|
// toDelete and the deleteMap.
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case len(names) > 0:
|
case len(names) > 0:
|
||||||
// prepare lookupOptions
|
// prepare lookupOptions
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package version
|
package version
|
||||||
|
|
||||||
// Version is the version of the build.
|
// Version is the version of the build.
|
||||||
const Version = "0.49.1-dev"
|
const Version = "0.49.2-dev"
|
||||||
|
|
|
@ -114,7 +114,7 @@ github.com/containers/buildah/pkg/rusage
|
||||||
github.com/containers/buildah/pkg/sshagent
|
github.com/containers/buildah/pkg/sshagent
|
||||||
github.com/containers/buildah/pkg/util
|
github.com/containers/buildah/pkg/util
|
||||||
github.com/containers/buildah/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
|
## explicit
|
||||||
github.com/containers/common/libimage
|
github.com/containers/common/libimage
|
||||||
github.com/containers/common/libimage/define
|
github.com/containers/common/libimage/define
|
||||||
|
|
Loading…
Reference in New Issue