image/save: Fix untagged images not present in index.json#47232
image/save: Fix untagged images not present in index.json#47232thaJeztah merged 3 commits intomoby:masterfrom
Conversation
Saving an image via digested reference, ID or truncated ID doesn't store the image reference in the archive. This also causes the save code to not add the image's manifest to the index.json. This commit explicitly adds the untagged manifests to the index.json if no tagged manifests were added. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
When saving an image treat `image@sha256:abcdef...` the same as `abcdef...`, this makes it: - Not export the digested tag as the image name - Not try to export all tags from the image repository Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
da0e203 to
fbe269f
Compare
fbe269f to
364316c
Compare
| } | ||
|
|
||
| manifestDesc.Annotations = map[string]string{ | ||
| "io.containerd.image.name": "docker.io/library/multilayer:latest", |
There was a problem hiding this comment.
I would really like to see these hard-coded values moved up the stack. With it like this it makes the test more confusing, for me, to work through.
Likewise with the layer contents.
There was a problem hiding this comment.
Extracted another function and moved the hardcoded values up. Let me know if that works for you!
|
@vvoland could you have a peek at the review comment above? |
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
364316c to
2ef0b53
Compare
|
Failures are Windows + containerd snapshotter, and are known to still fail, so can be ignored |
thaJeztah
left a comment
There was a problem hiding this comment.
quick blurb, as I started to look (so far nothing blocking) but had to drop off, so let me post what I had
| taggedManifest := untaggedMfstDesc | ||
| taggedManifest.Annotations = map[string]string{ | ||
| images.AnnotationImageName: ref.String(), | ||
| ocispec.AnnotationRefName: ref.Tag(), | ||
| } | ||
| manifestDescriptors = append(manifestDescriptors, taggedManifest) |
There was a problem hiding this comment.
I honestly somewhat more liked the struct-literal here, to prevent any possible confusion that things / fields could be used by-reference 🤔
It would result in some small amount of duplication (constructing the struct twice), just have been bit by maps or slices not being properly de-referenced on some occasions.
| taggedManifest := untaggedMfstDesc | ||
| taggedManifest.Annotations = map[string]string{ | ||
| images.AnnotationImageName: ref.String(), | ||
| ocispec.AnnotationRefName: ref.Tag(), |
There was a problem hiding this comment.
FWIW, it's fully valid for this to include the full reference:
There was a problem hiding this comment.
Hm.. interesting; so that would mean duplicating the same information (and implicitly; requiring the reader of that information having to parse the format to get the tag only?).
One thing I notice in that section is that it looks like separator as part of components seems to have been conflated with separator between name and tag (or digest);
- org.opencontainers.image.ref.name Name of the reference for a target (string).
SHOULD only be considered valid when on descriptors on
index.jsonwithin image layout.Character set of the value SHOULD conform to alphanum of
A-Za-z0-9and separator set of-._:@/+A valid reference matches the following grammar:
ref ::= component ("/" component)* component ::= alphanum (separator alphanum)* alphanum ::= [A-Za-z0-9]+ separator ::= [-._:@+] | "--"
The distribution/reference grammar uses a different definition;
separator := /[_.]|__|[-]*/
- it only allows
-._as separators - 2 consecutive underscores (
__) - zero or more hypens (
-)
The :, @ would be to separate tag or digest, and
If I read the OCI spec there correctly, something like docker.io/github.com/he:llo@sha256+fo--b_ar would be a valid value, but not parseable with the distribution/reference package 😬
There was a problem hiding this comment.
Hm.. for org.opencontainers.image.base.name, there's a mention that it should be in the format described in distribution/reference; should that also be done for the above?
- org.opencontainers.image.base.name Image reference of the image this image is based on (string)
- This SHOULD be image references in the format defined by [distribution/distribution][distribution-reference].
docker save <IMAGE>@<DIGEST>producesindex.jsonwith"manifest": null#47210Saving an image via digested reference, ID or truncated ID doesn't store the image reference in the archive. This also causes the save code to not add the image's manifest to the index.json.
This PR explicitly adds the untagged manifests to the index.json if no tagged manifests were added.
- How to verify it
By digest
By tag
Tag and digest
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)