-
Notifications
You must be signed in to change notification settings - Fork 102
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 should not be added to index.json
#664
Comments
Hi! I took a look at this and was able to avoid storing the manifests in diff --git a/content/oci/oci.go b/content/oci/oci.go
index 5c584f8..997543c 100644
--- a/content/oci/oci.go
+++ b/content/oci/oci.go
@@ -143,10 +143,6 @@ func (s *Store) Push(ctx context.Context, expected ocispec.Descriptor, reader io
if err := s.graph.Index(ctx, s.storage, expected); err != nil {
return err
}
- if descriptor.IsManifest(expected) {
- // tag by digest
- return s.tag(ctx, expected, expected.Digest.String())
- }
return nil
} $ sudo -E ./cmd/ig/ig image build -t execs -f gadgets/trace_exec/gadget.yaml gadgets/trace_exec
INFO[0000] Experimental features enabled
Successfully built docker.io/library/execs:latest@sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1
$ sudo cat /var/lib/ig/oci-store/index.json | jq main *% u=
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1",
"size": 491,
"annotations": {
"org.opencontainers.image.ref.name": "docker.io/library/execs:latest"
}
}
]
} The code I removed with the above patch was added in 4e58192 which description is the following:
So, I guess by removing the above code it breaks resolving a manifest by its digest? root@8db5c3d638c6:/mnt/oras-go# make test
...
coverage: 78.5% of statements
ok oras.land/oras-go/v2/registry/remote/retry 9.762s coverage: 78.5% of statements Moreover, applying the above patch on top of faaa1dd and modifying few stuff on Inspektor Gadget side, I can have everything removed while removing an image: $ sudo -E ./cmd/ig/ig image build -t execs -f gadgets/trace_exec/gadget.yaml gadgets/trace_exec
INFO[0000] Experimental features enabled
Successfully built docker.io/library/execs:latest@sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1
$ sudo ls /var/lib/ig/oci-store/blobs/sha256 francis/rmi-upstream *+%
225a8e697e260684d9451ccf8a622cd5548b0ae5fac6e13c416cd1d85247b7b7 b4be31f07444fb9be6dee8cd1349aab3c780d333b63406be10c5c14c1b39dd37
662ca58536d5a03864781eb42870f6712927981383f1dab1449d9adf80067313 c06a86dad7e582686b53bec9c729b92fc56c838b59cc11d0105c2c20f3158dcd
b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1 f61eef5ff800b2e4366c6d2e7311e95ce8dc3cff5c020a3a810429656fd93efb
$ sudo cat /var/lib/ig/oci-store/index.json | jq francis/rmi-upstream *+%
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1",
"size": 491,
"annotations": {
"org.opencontainers.image.ref.name": "docker.io/library/execs:latest"
}
}
]
}
$ sudo -E ./cmd/ig/ig run execs francis/rmi-upstream *+%
INFO[0000] Experimental features enabled
RUNTIME.CONTAINERNAME PID PPID UID GID RE… COMM
builder 48390 28015 0 0 0 ls
^C% $ sudo -E ./cmd/ig/ig image remove execs francis/rmi-upstream *+%
INFO[0000] Experimental features enabled
Successfully removed execs
$ sudo ls /var/lib/ig/oci-store/blobs/sha256 francis/rmi-upstream *+%
$ sudo cat /var/lib/ig/oci-store/index.json | jq francis/rmi-upstream *+%
{
"schemaVersion": 2,
"manifests": null
} Am I missing something, or the above patch can really change this behavior without breaking everything? Best regards. |
Yes, this is true. Since #385, we record every manifest in
So if you remove the code like that the above scenarios would be broken.
Mmm that shouldn't happen🤔 Can you try again? The diff you made will fail several cases in go test ./content/oci
--- FAIL: TestStore_Success (0.00s)
oci_test.go:144: resolver.Map() = 0, want 1
oci_test.go:162: Store.Resolve() = {application/octet-stream sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }, want {application/vnd.oci.image.manifest.v1+json sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }
--- FAIL: TestStore_RelativeRoot_Success (0.01s)
oci_test.go:273: resolver.Map() = 0, want 1
oci_test.go:291: Store.Resolve() = {application/octet-stream sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }, want {application/vnd.oci.image.manifest.v1+json sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }
--- FAIL: TestStore_DisableAutoSaveIndex (0.00s)
oci_test.go:614: resolver.Map() = 0, want 1
oci_test.go:623: Store.Resolve() = {application/octet-stream sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }, want {application/vnd.oci.image.manifest.v1+json sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }
--- FAIL: TestStore_RepeatTag (0.00s)
oci_test.go:703: len(resolver.Map()) = 0, want 1
oci_test.go:706: len(index.Manifests) = 0, want 1
oci_test.go:744: resolver.Map() = 2, want 3
oci_test.go:747: len(index.Manifests) = 1, want 2
--- FAIL: TestStore_TagByDigest (0.00s)
oci_test.go:881: len(resolver.Map()) = 0, want 1
oci_test.go:884: len(index.Manifests) = 0, want 1
oci_test.go:891: Store.Resolve() = {application/octet-stream sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }, want {application/vnd.oci.image.manifest.v1+json sha256:c824a9aa7d2e3471306648c6d4baa1abbcb97ff0276181ab4722ca27127cdba0 13 [] map[] [] <nil> }
--- FAIL: TestStore_ExistingStore (0.01s)
oci_test.go:1217: Store.Resolve() = {application/octet-stream sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }, want {application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }
oci_test.go:1289: Store.Predecessors(6) = [{application/vnd.oci.image.index.v1+json sha256:87a9ec2f8d3a785cdd39d52df3190bc989be8c526050a283636f3c5304b2ddc0 186 [] map[] [] <nil> }], want [{application/vnd.oci.image.index.v1+json sha256:87a9ec2f8d3a785cdd39d52df3190bc989be8c526050a283636f3c5304b2ddc0 186 [] map[] [] <nil> } {application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }]
oci_test.go:1289: Store.Predecessors(10) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:232a29e9b955c6cb5b3424f50d2d84bb4f5cabffffefb4e82a491a03747c4c98 351 [] map[] [] <nil> }]
oci_test.go:1289: Store.Predecessors(11) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }]
oci_test.go:1289: Store.Predecessors(13) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:232a29e9b955c6cb5b3424f50d2d84bb4f5cabffffefb4e82a491a03747c4c98 351 [] map[] [] <nil> }]
--- FAIL: TestReadOnlyStore_DirFS (0.01s)
readonlyoci_test.go:350: ReadOnlyStore.Resolve() = {application/octet-stream sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }, want {application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }
readonlyoci_test.go:413: ReadOnlyStore.Predecessors(6) = [{application/vnd.oci.image.index.v1+json sha256:87a9ec2f8d3a785cdd39d52df3190bc989be8c526050a283636f3c5304b2ddc0 186 [] map[] [] <nil> }], want [{application/vnd.oci.image.index.v1+json sha256:87a9ec2f8d3a785cdd39d52df3190bc989be8c526050a283636f3c5304b2ddc0 186 [] map[] [] <nil> } {application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }]
readonlyoci_test.go:413: ReadOnlyStore.Predecessors(10) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:232a29e9b955c6cb5b3424f50d2d84bb4f5cabffffefb4e82a491a03747c4c98 351 [] map[] [] <nil> }]
readonlyoci_test.go:413: ReadOnlyStore.Predecessors(11) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:063351176d525cd595e4741dbf2cbed7eb449534c7afc6ad9ae926da4ef24660 354 [] map[] [] <nil> }]
readonlyoci_test.go:413: ReadOnlyStore.Predecessors(13) = [], want [{application/vnd.oci.artifact.manifest.v1+json sha256:232a29e9b955c6cb5b3424f50d2d84bb4f5cabffffefb4e82a491a03747c4c98 351 [] map[] [] <nil> }]
FAIL
FAIL oras.land/oras-go/v2/content/oci 0.249s
FAIL |
Hi!
This makes sense!
Indeed, I got mixed up and I guess I tested without the patch applied 😅: root@c808884f4989:/mnt# make test
...
ok oras.land/oras-go/v2/registry/remote/retry 9.786s coverage: 78.5% of statements
FAIL
make: *** [Makefile:16: test] Error 1 Best regards. |
I tweaked a bit the code base to be able to reference manifest by their digest, the code can be found here: |
Hi! I continued my investigation and now I understand why you need to store the manifests in I will take the example of diff --git a/content/oci/oci.go b/content/oci/oci.go
index 997543c..c737796 100644
--- a/content/oci/oci.go
+++ b/content/oci/oci.go
@@ -429,13 +432,6 @@ func (s *Store) saveIndex() error {
tagged.Add(desc.Digest)
}
}
- // 2. Add descriptors that are not associated with any tag
- for ref, desc := range refMap {
- if ref == desc.Digest.String() && !tagged.Contains(desc.Digest) {
- // skip tagged ones since they have been added in step 1
- manifests = append(manifests, deleteAnnotationRefName(desc))
- }
- }
s.index.Manifests = manifests
return s.writeIndexFile()
You do not have troubles, as long as everything resides in memory. So, out of the blue, I think we need to explore the filesystem to create all the links. $ sudo cat /var/lib/ig/oci-store/index.json | jq francis/no-manifests-index *% u+2-2
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1",
"size": 491,
"annotations": {
"org.opencontainers.image.ref.name": "docker.io/library/execs:latest"
}
}
]
} We can find its associated manifests with: $ sudo cat /var/lib/ig/oci-store/blobs/sha256/b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1 | jq
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:662ca58536d5a03864781eb42870f6712927981383f1dab1449d9adf80067313",
"size": 581,
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:f61eef5ff800b2e4366c6d2e7311e95ce8dc3cff5c020a3a810429656fd93efb",
"size": 581,
"platform": {
"architecture": "arm64",
"os": "linux"
}
}
]
} And so on, we can get the layers with: $ sudo cat /var/lib/ig/oci-store/blobs/sha256/f61eef5ff800b2e4366c6d2e7311e95ce8dc3cff5c020a3a810429656fd93efb | jq
{
"schemaVersion": 2,
"config": {
"mediaType": "application/vnd.gadget.config.v1+yaml",
"digest": "sha256:b4be31f07444fb9be6dee8cd1349aab3c780d333b63406be10c5c14c1b39dd37",
"size": 1853,
"annotations": {
"org.opencontainers.image.title": "config.yaml"
}
},
"layers": [
{
"mediaType": "application/vnd.gadget.ebpf.program.v1+binary",
"digest": "sha256:c06a86dad7e582686b53bec9c729b92fc56c838b59cc11d0105c2c20f3158dcd",
"size": 125232,
"annotations": {
"org.opencontainers.image.authors": "TODO: authors",
"org.opencontainers.image.description": "TODO: description",
"org.opencontainers.image.title": "program.o"
}
}
]
} First of all, is my understanding correct? Best regards. |
OK, I took another look and my conclusion were not really accurate.
$ sudo cat /var/lib/ig/oci-store/index.json | jq francis/fsslower-statfs *% u=
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:b0eff7f0ec2a27b8d71fe904cf373fa2002c6d669db54c25a9542cf2cb5f46d1",
"size": 491,
"annotations": {
"org.opencontainers.image.ref.name": "docker.io/library/execs:latest"
}
}
]
} On the other hand, manifests which do not have predecessors, like oras-go/content/oci/readonlyoci_test.go Line 291 in d1becd5
What do you think? |
Hi @eiffel-fl ! Basically, we need to ensure that:
Additionally, it is not necessary to record nodes in
|
Hi!
Indeed, more discussion are needed as this problem is not trivial to solve.
I do not have a patch for this at the moment and I will need to think more about the consequences.
To resolve manifests with their digest, I wrote this patch:
Indeed, if there is a path to a manifest, we do not need to store it in Best regards. |
Hi @eiffel-fl , after an offline discussion, we realized that we still want all manifests to be recorded in
The idea is that every manifest is a root of an artifact, so it should be in the list of roots ( Since there is no change in the design of
To resolve your original concern:
We re-consider the definition of garbage produced by |
Hi!
With regard to the spec, this definitely makes sense!
I will for sure take a look at it 👀! Best regards. |
Closing this issue as:
With regard to this:
I wrote this commit: |
Related to #664 Signed-off-by: Xiaoxuan Wang <wangxiaoxuan119@gmail.com>
Hi @eiffel-fl , I'm wondering why do you need this change? Using the current implantation, you should be able to resolve a manifest with the correct media type by its digest. |
Hi!
I personally do not need this code, all I needed was already perfectly merged in #680. Best regards. |
@eiffel-fl See Lines 282 to 294 in 66ea3df
|
Indeed! Thank you for sharing :D! |
Hi!
Manifests are added to
index.json
:This behavior can create troubles, as when the manifests in
index.json
will not be automatically deleted when the surroundingindex
is deleted:Sadly, this behavior is not straightforward to modify.
So, I open this issue to discuss a proper design.
Best regards.
The text was updated successfully, but these errors were encountered: