-
Notifications
You must be signed in to change notification settings - Fork 100
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
[Bug]: Nested index: is it normal for an index to be deleted if its tag is deleted even when it is part of another index #2624
Comments
@Sebastian-Maier thanks for trying zot out. Yes, this is likely a bug. However, just curious, is this just an experiment or a concrete use case - so we can prioritize. |
Hi @Sebastian-Maier, Do you have retention / gc settings enabled? Let me see if I understand the scenario:
If GC is enabled and set to delete untagged images after a while, it could delete A because it is not referenced in another image, and it is not tagged. If at point 1 you actually tagged A separately, it should be retained regardless of removing B. If by "root index" you mean the index zot manages internally for tracking all images pushed to a specific repo, that one is managed by zot, and zot can add or removed images when the user calls the respective APIs or when GC runs. |
We currently use this nested index in a PoC implementation but we plan to use it in production soon. |
I use the docker image with the default settings. Not sure what that means for the setting, but I would expect that the nested index that is still referenced from another index is not deleted in either of these modes.
The scenario I described was a little bit different.
By root index I mean my own index "R" that references the nested index "N" and should be the only one that has a tag in the end. I also opened an issue/question for regclient to find out whether this is a ZOT or |
I got an update from the maintainers of regclient: It is possible to use
This seems to work, as "N" seems to be accessible via its digest – at least initially. However, I am not sure whether some kind of GC might eventually delete "N" nevertheless. In addition, I also think the original behavior (from the steps we discussed before) is probably still a bug. |
@Sebastian-Maier can you share your zot config file (anonymized of course), so we may try to understand and reproduce this locally. |
We currently do not use a custom ZOT config file. But below you'll find two scripts that start ZOT (in the same way we do) and in addition also implement the two approaches described above.
#!/usr/bin/env bash
set -eu
CONT_NAME="zot-nested-index-test"
PORT=60000
TMP_DIR=${PWD}/tmp/${CONT_NAME}/registry-storage
perform_cleanup(){
docker rm \
-f \
"${CONT_NAME}" &> /dev/null
rm -rf $TMP_DIR
}
trap perform_cleanup EXIT
mkdir -p $TMP_DIR
docker run \
-d \
-p ${PORT}:5000 \
--name "${CONT_NAME}" \
-v ${TMP_DIR}:/var/lib/registry \
ghcr.io/project-zot/zot-linux-arm64:latest # adjust architecture according to your needs
SOME_IMAGE_INDEX=ghcr.io/regclient/regctl:latest
regctl image copy $SOME_IMAGE_INDEX localhost:$PORT/repo:tagN
DIGEST=$(regctl manifest head localhost:$PORT/repo:tagN)
echo "Digest (nested index): $DIGEST"
INFO=$(regctl manifest get --format raw-body localhost:$PORT/repo:tagN)
echo "Nested Index:"
echo $INFO | jq .
SIZE=$(echo $INFO | wc -c | xargs echo) # xargs echo to trim whitespace
TYPE=$(echo $INFO | jq --raw-output .mediaType)
INDEX="{
\"schemaVersion\":2,
\"mediaType\":\"application/vnd.oci.image.index.v1+json\",
\"manifests\":[{
\"mediaType\":\"$TYPE\",
\"size\":$SIZE,
\"digest\":\"$DIGEST\"
}]
}"
echo "Root Index:"
echo $INDEX | jq .
echo $INDEX | regctl manifest put localhost:$PORT/repo:tagR
regctl tag delete localhost:$PORT/repo:tagN
# sleep 10
regctl manifest get localhost:$PORT/repo@$DIGEST # this fails unexpectedly
#!/usr/bin/env bash
set -eu
CONT_NAME="zot-nested-index-test"
PORT=60000
TMP_DIR=${PWD}/tmp/${CONT_NAME}/registry-storage
perform_cleanup(){
docker rm \
-f \
"${CONT_NAME}" &> /dev/null
rm -rf $TMP_DIR
}
trap perform_cleanup EXIT
mkdir -p $TMP_DIR
docker run \
-d \
-p ${PORT}:5000 \
--name "${CONT_NAME}" \
-v ${TMP_DIR}:/var/lib/registry \
ghcr.io/project-zot/zot-linux-arm64:latest # adjust architecture according to your needs
SOME_IMAGE_INDEX=ghcr.io/regclient/regctl:latest
DIGEST=$(regctl manifest head $SOME_IMAGE_INDEX)
echo "Digest (nested index): $DIGEST"
regctl image copy $SOME_IMAGE_INDEX localhost:$PORT/repo@$DIGEST
INFO=$(regctl manifest get --format raw-body localhost:$PORT/repo@$DIGEST)
echo "Nested Index:"
echo $INFO | jq .
SIZE=$(echo $INFO | wc -c | xargs echo) # xargs echo to trim whitespace
TYPE=$(echo $INFO | jq --raw-output .mediaType)
INDEX="{
\"schemaVersion\":2,
\"mediaType\":\"application/vnd.oci.image.index.v1+json\",
\"manifests\":[{
\"mediaType\":\"$TYPE\",
\"size\":$SIZE,
\"digest\":\"$DIGEST\"
}]
}"
echo "Root Index:"
echo $INDEX | jq .
echo $INDEX | regctl manifest put localhost:$PORT/repo:tagR
# sleep 10
regctl manifest get localhost:$PORT/repo@$DIGEST # this succeeds (at least initially ?) |
It's OK, I managed to reproduce yesterday, we are discussing how to best fix this. |
If you are ok with it, can you pls try this patch and verify that it indeed solves your particular use case. |
Thanks for all your efforts to fix this bug. |
PR #2626 is now merged. Closing this issue. |
More tests for GC, covering indexes referencing other indexes: #2716 |
This one also solved some issues with the UI and CVE scan breaking for nested indexes: #2732 |
zot version
v2.1.1
Describe the bug
I have the following questions (not sure whether this is actually a bug):
I want to copy a multi-platform image (index) to a repository (via
regctl image copy
) and include its digest as an platform-independent entry in another multi-platform image (index) that I add to the same repository.Since I do no longer need (nor want) a specific tag referencing the copied image, I delete it (with
regctl tag delete
).All these operations succeed. However when I try to access/retrieve the image copied originally (via the digest stored in the root index), the image is no longer available.
Is this normal behavior even when the image/index is still referenced (via digest in the root index)?
Is this an OCI registry or a client tool issue? (I use ZOT v2.1.1 and regctl v0.7.1 on macOS)
Is there a way to copy a multi-platform image (index) without a specific target tag in the first place?
To reproduce
regctl image copy
)regctl tag delete
)Expected behavior
I would expect the copied image to be still available since it is referenced via digest by the (root) index.
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: