Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest: Make sure manifest rm only removes manifests not referenced images. #3492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/buildah/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ func manifestRmCmd(c *cobra.Command, args []string) error {
}

options := &libimage.RemoveImagesOptions{
Filters: []string{"readonly=false"},
Filters: []string{"readonly=false"},
LookupManifest: true,
}
rmiReports, rmiErrors := runtime.RemoveImages(context.Background(), args, options)
for _, r := range rmiReports {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/containerd/containerd v1.5.5
github.com/containernetworking/cni v0.8.1
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25
github.com/containers/image/v5 v5.16.0
github.com/containers/ocicrypt v1.1.2
github.com/containers/storage v1.35.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f h1:aK7C516naCNpgksPPM9qAs5wgfmeeKtp1NlLREvMy7A=
github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f/go.mod h1:NIymxA8e3mUVnLoeGFoDgIrJeUmVA/djOqgMmO112Qw=
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25 h1:zcFtn+MuCwpywchrRtZjFQxTJIcNb9vjlIeZktYgSzQ=
github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25/go.mod h1:NIymxA8e3mUVnLoeGFoDgIrJeUmVA/djOqgMmO112Qw=
github.com/containers/image/v5 v5.16.0 h1:WQcNSzb7+ngS2cfynx0vUwhk+scpgiKlldVcsF8GPbI=
github.com/containers/image/v5 v5.16.0/go.mod h1:XgTpfAPLRGOd1XYyCU5cISFr777bLmOerCSpt/v7+Q4=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
Expand Down
17 changes: 17 additions & 0 deletions tests/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@ load helpers
run_buildah 125 rm -a "$cid"
expect_output --substring "when using the --all switch, you may not pass any containers names or IDs"
}

@test "remove a single tagged manifest list" {
_prefetch busybox
run_buildah manifest create manifestsample
run_buildah manifest add manifestsample busybox
run_buildah tag manifestsample manifestsample2
run_buildah manifest rm manifestsample2
# Output should only untag the listed manifest nothing else
expect_output "untagged: localhost/manifestsample2:latest"
flouthoc marked this conversation as resolved.
Show resolved Hide resolved
run_buildah manifest rm manifestsample
# Since actual list is getting removed it will also print the image id of list
# So check for substring instead of exact match
expect_output --substring "untagged: localhost/manifestsample:latest"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless this is covered by another test, verifying that the image we added to the list (busybox) is still present would at least make me feel better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nalind That's a very fair request. Similar check was added in podman for this fix adding it here as well. :)

# Check if busybox is still there
run_buildah images
expect_output --substring "busybox"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion vendor/github.com/containers/common/libimage/runtime.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ github.com/containernetworking/cni/pkg/types/020
github.com/containernetworking/cni/pkg/types/current
github.com/containernetworking/cni/pkg/utils
github.com/containernetworking/cni/pkg/version
# github.com/containers/common v0.43.3-0.20210830085322-6143ffe54e5f
# github.com/containers/common v0.43.3-0.20210902095222-a7acc160fb25
github.com/containers/common/libimage
github.com/containers/common/libimage/manifests
github.com/containers/common/pkg/apparmor
Expand Down