Repository navigation
Open
Labels
bugSomething isn't working
Description
Description
Most likely related to #3435.
When using the GKE image streaming snapshotter, converting an image after we commit it locally from a running container (e.g. with docker), the converter tries to pull the image from remote which then fails (because we haven't pushed it).
The image is present in the snapshotter (as we can run it) but apparently not in the content store.
Steps to reproduce the issue
> docker run --name foo alpine
> docker commit foo gcr.io/$repo/cbruckmayer:foo
# I can use the image with nerdctl
> nerdctl --address /var/run/docker/containerd/containerd.sock --namespace moby --snapshotter gcfs run -it --network none gcr.io/$repo/cbruckmayer:foo
# However, when trying to convert the image, it will try to pull it from remote which fails with not found
> nerdctl --address /var/run/docker/containerd/containerd.sock --namespace moby --snapshotter gcfs image convert --zstd --oci gcr.io/$repo/cbruckmayer:foo gcr.io/$repo/cbruckmayer:foo-zstd
gcr.io/$repo/cbruckmayer:foo: resolving |--------------------------------------|
elapsed: 0.1 s total: 0.0 B (0.0 B/s)
INFO[0000] fetch failed after status: 404 Not Found host=gcr.io
FATA[0000] failed to resolve reference "gcr.io/$repo/cbruckmayer:foo": gcr.io/$repo/cbruckmayer:foo: not found
root@docker-daemon-rzhtc:/app# nerdctl --debug-full --address /var/run/docker/containerd/containerd.sock --namespace moby --snapshotter gcfs image convert --zstd --oci gcr.io/$repo/cbruckmayer:foo gcr.io/$repo/cbruckmayer:foo-zstd
DEBU[0000] fetching image="gcr.io/$repo/cbruckmayer:foo"
DEBU[0000] resolving host=gcr.io
DEBU[0000] do request host=gcr.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=containerd/2.0.0+unknown request.method=HEAD url="https://gcr.io/v2/$repo/cbruckmayer/manifests/foo"
DEBU[0000] fetch response received host=gcr.io response.header.accept-ranges=none response.header.content-type=application/json response.header.date="Fri, 13 Dec 2024 13:10:25 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.server="Docker Registry" response.header.vary=Accept-Encoding response.header.www-authenticate="Bearer realm=\"https://gcr.io/v2/token\",service=\"gcr.io\",scope=\"repository:$repo/cbruckmayer:pull\"" response.header.x-frame-options=SAMEORIGIN response.header.x-xss-protection=0 response.status="401 Unauthorized" url="https://gcr.io/v2/$repo/cbruckmayer/manifests/foo"
DEBU[0000] Unauthorized header="Bearer realm=\"https://gcr.io/v2/token\",service=\"gcr.io\",scope=\"repository:$repo/cbruckmayer:pull\"" host=gcr.io
DEBU[0000] do request host=gcr.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent=containerd/2.0.0+unknown request.method=HEAD url="https://gcr.io/v2/$repo/cbruckmayer/manifests/foo"
DEBU[0000] fetch response received host=gcr.io response.header.accept-ranges=none response.header.content-type=application/json response.header.date="Fri, 13 Dec 2024 13:10:25 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.server="Docker Registry" response.header.vary=Accept-Encoding response.header.x-frame-options=SAMEORIGIN response.header.x-xss-protection=0 response.status="404 Not Found" url="https://gcr.io/v2/$repo/cbruckmayer/manifests/foo"
INFO[0000] fetch failed after status: 404 Not Found host=gcr.io
FATA[0000] failed to resolve reference "gcr.io/$repo/cbruckmayer:foo": gcr.io/shopify-docker-images/cbruckmayer:foo: not found
Describe the results you received and expected
I expect to be able to convert (tagging, committing, saving) the image.
What version of nerdctl are you using?
> nerdctl --address /var/run/docker/containerd/containerd.sock --namespace moby version
Client:
Version: v2.0.2
OS/Arch: linux/amd64
Git commit: 1220ce7ec2701d485a9b1beeea63dae3da134fb5
buildctl:
Version:
Server:
containerd:
Version: 1.7.24
GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc:
Version: 1.2.2
GitCommit: v1.2.2-0-g7cb3632
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
Host information
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
apostasie commentedon Dec 16, 2024
Thanks @ChrisBr
Looking.
apostasie commentedon Dec 16, 2024
Ok, @ChrisBr. Here is my understanding here.
Of course I may be wrong or missing something - this part of things is not exactly trivial... So, tagging @lingdie and @AkihiroSuda to keep me in checks...
So:
Because containerd is lazily retrieving images, said images may be incomplete / missing layers on the host machine, even if they have ran.
This is normally fine, though it is not in some circumstances (commit, save, convert) <- because these operations (obviously) require all of the content to be here.
Since containerd does not currently have a solution for that problem, nerdctl has implemented logic (in #3435 and others) that will verify that images are complete before said operations, and if layers are missing, retrieve them from their origin (note that we have to extend that logic to
tagas well).This approach is obviously not bullet-proof. If there are indeed missing layers, and the remote image has vanished, or cannot be reached, then we (must) fail.
I believe what is happening for you here is:
nerdctl/pkg/cmd/image/ensure.go
Lines 40 to 76 in 7e97f06
Unfortunately, there might not be anything that could be done inside nerdctl per-se.
We could "soft-error", but then what would happen is that the
convertoperation WILL fail after that, as layers are missing.This is a situation where content is not there, and we have no idea / information on how to retrieve it.
Please note though that my understanding of GKE snapshotter is very superficial.
So, here are two things we could try to confirm above:
^ I would expect this to fail
ChrisBr commentedon Dec 16, 2024
Thanks for the detailed write up @apostasie, really appreciated. This makes sense but is of course unfortunate for our use case 😿
I will try this tomorrow morning and will report back. Could you maybe clarify why it would work with nerdctl (if nerdctl were to use GKE snapshotter as well) and not with docker?
ChrisBr commentedon Dec 16, 2024
If there would be a way with the GKE snapshotter to force download the base image, would you expect this work?
Pseudo code
apostasie commentedon Dec 16, 2024
It would work with nerdctl, because nerdctl will force content download when you
commit(at that time, we do know the image isalpine, and retrieving the missing layers will work). Further operations after that will recon the image is complete, and should succeed without trying to download anything.apostasie commentedon Dec 16, 2024
Mmmm...
I am not 100% comfortable about the interactions between containerd and the GKE snapshotter, but I would say "yes it should work" cautiously.
You should be able to check images status using
ctr:Should tell you which images are fully locally available, and which have missing layers.
ChrisBr commentedon Dec 17, 2024
Ok did some testing this morning
Using nerdctl like this works
Using docker save works as well even though image seems incomplete 🤔
Do you think we could pull the images with ctr / nerdctl to force them available (e.g. use overlay as snapshotter)?
apostasie commentedon Dec 17, 2024
Something like that should work:
Then you do your normal stuff after that with docker / etc.
Tagging with nerdctl will force fetch the missing layers.
Check with ctr that you get the expected results ^.
I appreciate none of this is cute... we do have a serious problem here. But so far, there is no good solution...
apostasie commentedon Dec 17, 2024
Concerning.
Does the saved tarball contain everything or just bits and pieces?
ChrisBr commentedon Dec 17, 2024
Any easy way to confirm?
Yeah appreciate your help, difficult corner case here ... 😿
apostasie commentedon Dec 17, 2024
I think so: save it with docker like you just did (possibly incomplete) - then remove everything and just use nerdctl (pull alpine, save alpine), then extract both archives and diff.
ChrisBr commentedon Jan 2, 2025
Happy new year!
This seems to work and would unblock us. Thanks for the help!
ChrisBr commentedon Jan 17, 2025
@apostasie I appreciate this might only be tangible related but we're seeing issues when a zstd converted image is not fully imported in the containerd content store.
Here is an example of two manifests
Image 2 builds on top of image 1, so the layers should be all shared.
If I pull image 1 first I end up with
Image 1 is fully available but image 2 is incomplete? I can run the image regardless so my gut feeling is that the content store is not able to make the connection that the layer is available but in a different compression format?
If I only pull image 2, it will be fully available.
Is there anything you can think of causing this?
8 remaining items
apostasie commentedon Mar 17, 2025
Thanks.
So, let's start with this.
Is the following
./thing.shbelow faithful to what you are doing?If yes, can you
while true; do sudo ./thing.sh; doneand confirm that it does break for you after some time?apostasie commentedon Apr 18, 2025
@ChrisBr
We recently merged:
[MAJOR] content digest not found) #4062They are all related to the overall issue of (likely) certain layers being garbage collected breaking operations like
convert.I believe your latest issue here might have been fixed by one of the above (most likely #4121).
If you do get a chance, would love to see you try the latest nerdctl
main(or if you prefer to wait, the next patch release).Also, if you ever see again
digest content not found, I would love to hear from it.apostasie commentedon Apr 19, 2025
Actually - @AkihiroSuda suggesting we close this as resolved.
This ticket has gone to a range of different places and different problems and questions, and it is no longer clear what it is about or what issue it describes - except of course @ChrisBr last mention of failed
convert, which I believe is fixed now.@ChrisBr if it turns out this is not fixed, I would owe you an apology (and a beer on me, the next time I am in Cambridge :-)) and would of course look at any new details on this. Cheers!
ChrisBr commentedon Apr 22, 2025
Amazing, thank you! Any rough idea when you do the next patch release?
apostasie commentedon Apr 22, 2025
@ChrisBr:
@AkihiroSuda just opened #4149 - so, let's conservatively say a couple of weeks?
About this here, I want to change my statement from "yeah, it's fixed!", to "cautiously, this should be fixed".
The good news is that we have a much better grasp of what is happening when
convertscrews the pooch - the bad news is that there may still be (the same) lingering issue in dependencies (stargz/zstd) and we might have to do multiple careful reviews, deep in there. So, if it happens again (when you will run the new version), open a new ticket with as much detail as you can and I'll have a look.Cheers!
ChrisBr commentedon Jun 6, 2025
@apostasie I've updated to 2.0.5 but we're still seeing this issue. I'm not able to manually reproduce it but it happens fairly regularly in our build infrastructure (10s of times per day) so maybe you can advise to add some strategic log output which would help debug this further?
ChrisBr commentedon Jun 6, 2025
We also see cases of
already existerrors which I'm not able to reproduce 🤔apostasie commentedon Jun 6, 2025
Damn.
@ChrisBr yes, if you are still motivated, let's come up with a repro.
Can we start with #3764 (comment) <- lmk if we can build something like that reproduces the issue?
apostasie commentedon Jun 13, 2025
@AkihiroSuda let's reopen this. One way or the other, something is still wrong in convert with --ztsd.
ChrisBr commentedon Jul 2, 2025
@apostasie I'm not able to make this reproducible but it happens multiple times in our system per day.
The odd thing is that the very image we've just committed does have missing layers even though we've pulled / tagged the parent image.
The parent image is fully present in the store
As next step we run and build the new image.
and then convert it
This image seems to have missing layers in the store and hence fails.
Can you think of anything how a freshly built image can have missing layers? Can you think of a workaround?
lingdie commentedon Jul 3, 2025
Is the storage for the /var/run/docker/containerd/ directory sufficient?
ChrisBr commentedon Jul 3, 2025
You mean running out of disk space?
lingdie commentedon Jul 4, 2025
The possible cause of the problem that I'm speculating about - we've encountered this before - is that containerd garbage-collected the blob that had just finished being pulled.