-
-
Couldn't load subscription status.
- Fork 122
fix: add content-create events for image tag #978
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
base: main
Are you sure you want to change the base?
Conversation
Resolve the image digest and walk image for all content.
|
The code could be helped with some more comments and explicit tests to show the expected behavior. What happens when an image is pulled with Containerd is that two image create events are created. One event for the image tag reference and one for the digest. In Containerd 1.7 you would only see the image create events and none of the content create events. What we want to avoid is creating duplicate events for the same content, as advertising content has a cost associated with it. So what we do is when the image tag event comes we return immediately. For the image create event with the digest if content create events are not supported we will walk the image and create events for all the layers. If we did this for the image tag event we would create duplicate events. Now for Containerd 2.1 image create events are only needed for the tag event as all of the digests also create content create events already. How are you observing that newly created images are not being advertised? |
I'm observing different behavior using containerd 1.7 and the Run Using Judging from the Indeed, the CRI implementation of |
|
Spegel is specifically developed to work with CRI and Containerd, as that is what the kubelet uses to pull images. In what use case do you need to use ctr to pull images together with Spegel? |
Based on #829, I was under the impression that Kubernetes/CRI was not a fixed requirement, and I assumed that improving Spegel's compatibility for a use-case involving Containerd directly would be in scope of this project. If I was mistaken on this and using Spegel via Containerd's Kubernetes/CRI plugin will continue to be a requirement moving forward, feel free to close this compatibility-fix PR as being out of scope.
My use-case is a Golang program that interacts directly with Containerd on the host to pull images from remote registries, with Spegel running directly on the host (as a systemd service), configured as a registry mirror. This program doesn't invoke |
|
#829 would still assume that interactions with Containerd would be done through CRI. I am not directly opposed to fixing the events to support both pulling images through ctr and cri. This would however require expanding unit tests to cover the following cases. The easiest method would be to take the raw json events and replay them through the event conversion function. These cases doubled up, once when content events are supported and once when content events are not supported.
The events produced should be assumed to be the same for both methods, without any duplicate digests. The main difference being that when pulling by tag the tag is also included in the events. |
While working on #977, I found that newly-pushed images were not immediately advertising their associated content, and learned that for containerd versions not supporting native content-create events, the logic to create
OCIEventfrom images was explicitly skipped for tag-referenced images:spegel/pkg/oci/containerd.go
Lines 456 to 459 in a78e9f4
This PR fixes the issue by resolving the image digest from the tag and allows the existing logic to walk the image to create associated content events.
(note: this fix works for my case, but I'm not 100% confident it will work in the general case since I didn't fully understand the existing comment about advertising twice. In my own tests, I only saw a single
/images/createevent when pulling an image by tag. My tests were on containerd v1.7.20 in case version-specific behavior is related.)