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

Fix duplicate image entries in k8s.io namespaces #3744

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fengwei0328
Copy link

@fengwei0328 fengwei0328 commented Dec 10, 2024

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

This should be opt-in via a config entry like --kube-hide-dupe:
https://github.com/containerd/nerdctl/blob/main/docs/config.md

@fengwei0328
Copy link
Author

This should be opt-in via a config entry like --kube-hide-dupe: https://github.com/containerd/nerdctl/blob/main/docs/config.md

Okay, I'll try to implement it. Initially, I wanted to implement it separately, but this is a preliminary version for the sake of testing and discussion.

pkg/cmd/image/list.go Outdated Show resolved Hide resolved
@fengwei0328 fengwei0328 force-pushed the dev1 branch 7 times, most recently from bf3dfaa to 9851575 Compare December 17, 2024 13:17
pkg/cmd/image/list.go Outdated Show resolved Hide resolved
pkg/cmd/image/list.go Outdated Show resolved Hide resolved
@fengwei0328 fengwei0328 force-pushed the dev1 branch 2 times, most recently from d5c7e2f to 086f530 Compare December 18, 2024 03:48
docs/config.md Outdated Show resolved Hide resolved
@@ -351,3 +351,110 @@ func TestIssue3016(t *testing.T) {

testCase.Run(t)
}

func TestRemoveKubeWithKubeHideDupe(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

@apostasie Could you take a look?
Is this correct?
The test doesn't seem to involve with Kube

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AkihiroSuda

This is correct.

Repro locally:

# This creates the kind / kube cluster and configure what needs be
./hack/build-integration-kubernetes.sh
# Jump into the control plane to gain access to the created cluster
nerdctl exec -ti nerdctl-test-control-plane bash

This ^ is exactly what the CI is doing

Now that you are in the control plane, use nerdctl against the kind cluster:

nerdctl --namespace k8s.io images
nerdctl --namespace k8s.io pull busybox
nerdctl --namespace k8s.io images

^ now, 2919d0172f75 (in my case, on arm) appears as busybox and none/none

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct.

What I mean is: the test is actually doing what it says, and does interact with Kube, as nerdctl is interacting with the kind cluster and the k8s.io namespace

pkg/cmd/image/list.go Outdated Show resolved Hide resolved
pkg/cmd/image/list.go Outdated Show resolved Hide resolved
Copy link
Contributor

@apostasie apostasie left a comment

Choose a reason for hiding this comment

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

Thanks a lot @fengwei0328

I left a few comments.

if err != nil {
continue
}
if _, ok := parsed.(reference.Tagged); ok {
Copy link
Author

Choose a reason for hiding this comment

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

#3744 (comment) @apostasie
Here, I need to obtain the interface corresponding to the image name, and then use interface.type to distinguish whether it's a standard tag( reference.Tagged) or a non-standard tag().
I simply expected standard implementation, but referenceutil.Parse works too.

@fengwei0328 fengwei0328 force-pushed the dev1 branch 5 times, most recently from dbd059c to 7173cb6 Compare December 23, 2024 09:28
The same imageId underk8s.io is showing multiple results: repo:tag, repo:digest, configID.
We expect to display only repo:tag, consistent with other namespaces and CRI.
		e.g.
		nerdctl -n k8s.io images
		REPOSITORY    TAG       IMAGE ID        CREATED        PLATFORM       SIZE         BLOB SIZE
		centos        7         be65f488b776    3 hours ago    linux/amd64    211.5 MiB    72.6 MiB
		centos        <none>    be65f488b776    3 hours ago    linux/amd64    211.5 MiB    72.6 MiB
		<none>        <none>    be65f488b776    3 hours ago    linux/amd64    211.5 MiB    72.6 MiB

		expect:
		nerdctl --kube-hide-dupe -n k8s.io images
		REPOSITORY    TAG       IMAGE ID        CREATED        PLATFORM       SIZE         BLOB SIZE
		centos        7         be65f488b776    3 hours ago    linux/amd64    211.5 MiB    72.6 MiB
Of course, even after deduplicating the images displayed, there are still issues with deleting the images.
It is necessary to distinguish between repo:tag and configId, as well as repoDigest. Considering the situation with tags,
we need to ensure that all repo:tags under the same imageId are cleaned up before proceeding to clean up the configId and repoDigest.

see: containerd#3702

Signed-off-by: fengwei0328 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants