Conversation
9d68e75 to
3507b41
Compare
fc27649 to
f7c6a83
Compare
| compatibility. | ||
| type: "array" | ||
| x-nullable: false | ||
| x-omitempty: true |
There was a problem hiding this comment.
Hmm CI fails with:
diff --git a/api/types/image/summary.go b/api/types/image/summary.go
index 4ebbdeadf7..fed2746521 100644
--- a/api/types/image/summary.go
+++ b/api/types/image/summary.go
@@ -54,7 +54,7 @@ type Summary struct {
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
//
- PlatformImages []PlatformImage `json:"PlatformImages,omitempty"`
+ PlatformImages []PlatformImage `json:"PlatformImages"`
// List of content-addressable digests of locally available image manifests
// that the image is referenced from. Multiple manifests can refer to the
Please update api/swagger.yaml with any API changes, then
run hack/generate-swagger-api.sh.
Even though I marked this one with x-omitempty 🤔
There was a problem hiding this comment.
Looks like it's an issue with the outdated go-swagger, see #47827 for update
There was a problem hiding this comment.
Disabled swagger model generation for this struct: 5eb892a
f7c6a83 to
ea31ce0
Compare
7a67112 to
5eb892a
Compare
|
moby/api/types/image/summary.go Lines 50 to 58 in 5eb892a Thinking about it a bit more, I think we might want to expose all manifests details, not only the platform-specific images, so we can also provide information about build attestations (and possibly other things in future). // Manifests is a list of image manifests available in this image. It
// provides a more detailed view of the platform-specific image manifests or
// other image-attached data like build attestations.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
//
Manifests []ImageManifestSummary `json:"Manifests,omitempty"`type ImageManifestKind string
const (
ImageManifestKindImage ImageManifestKind = "image"
ImageManifestKindAttestation ImageManifestKind = "attestation"
ImageManifestKindUnknown ImageManifestKind = "unknown"
)
type ImageManifestSummary struct {
ID string `json:"Id"`
Descriptor ocispec.Descriptor `json:"Descriptor"`
Available bool `json:"Available"`
ContentSize int64 `json:"ContentSize"`
Kind ImageManifestKind `json:"Kind"`
// Fields below are specific to the kind of the image manifest.
// Present only if Kind == ImageManifestKindImage.
ImageData ImageProperties `json:"ImageData,omitempty"`
// Present only if Kind == ImageManifestKindAttestation.
AttestationData AttestationProperties `json:"AttestationData,omitempty"`
}
type ImageProperties struct {
Platform ocispec.Platform `json:"Platform"`
UnpackedSize int64 `json:"UnpackedSize"`
Containers int64 `json:"Containers"`
}
type AttestationProperties struct {
// For - the digest of the image manifest that this attestation is for.
For digest.Digest `json:"For"`
}This would also leave the gate open for adding any other manifests types in future. WDYT? |
5eb892a to
1db8418
Compare
e1e2554 to
3adc348
Compare
02ca88a to
eab3e7b
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
overall LGTM
I left one comment about sizes; wondering if you (and others) have thoughts on that. Also still a bit sad about the attestations bit (and we need to double-check how signing will work if we don't want the enum for "Kind" to become an unbounded list 🙈 )
api/swagger.yaml
Outdated
| AvailableContentSize: | ||
| description: | | ||
| The size of the available distributable (possibly compressed) image content | ||
| in bytes. | ||
| type: "integer" |
There was a problem hiding this comment.
This does not include the unpacked content, correct? never mind; that's indeed further down.
One thing I was considering; would it make sense to combine these? Thinking;
Size
- packed
- unpacked
With the potential to add (e.g.) size of the manifest itself.
My thinking there is that it could (possibly) allow formatting "size" as either a combined output (including a total), or as detailed, but encapsulate all of that in a combined struct about "size".
There was a problem hiding this comment.
I think it's fine, but that would have to go into ImageData:
- The top "manifest" level shouldn't do too much interpretation. That's why there's only raw content size.
- The unpacked size doesn't make sense for all manifests - attestations can't be unpacked.
With the potential to add (e.g.) size of the manifest itself.
Manifest size is already available in the Descriptor.
There was a problem hiding this comment.
Grouped under Size but actually didn't add the packed one - it would be the same as AvailableContentSize.
Added a Size group to the top-level manifest that contains:
Content- size of the locally available content in the content storeTotal- total size of the content AND all the kind-specific sizes (Total-Content = size remaining in theXDatastruct).
Does that LGTY?
api/types/image/manifest.go
Outdated
| // Present only if Kind == ImageManifestKindAttestation. | ||
| AttestationData AttestationProperties `json:"AttestationData,omitempty"` |
There was a problem hiding this comment.
I'm also somewhat preparing for other things like signing etc.
Note to self; we need to check what plans are in that area, and how such information would be made available.
api/types/image/manifest.go
Outdated
| // Platform is the OCI platform object describing the platform of | ||
| // | ||
| // Required: true | ||
| Platform ocispec.Platform `json:"Platform"` |
There was a problem hiding this comment.
Ugh. Forgot about those 😞
ISTR there was still a discussion ongoing about some of that (i.e., badly built cross-compiled images that may have non-matching platforms in both). I'd have to dig back where that was.
api/swagger.yaml
Outdated
| The number of containers that are using this specific platform image. | ||
| type: "integer" | ||
| format: "int64" | ||
| example: 2 |
There was a problem hiding this comment.
Just slightly worried about list becoming an inspect 😅.
Yeah, I can see where you're coming from. I think it may be fine to use a list for this here. Or at least, it makes the content probably a lot more useful than just a number 🤔 (but happy to discuss)
eab3e7b to
da1fa10
Compare
c05ec81 to
49851df
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Thanks! This starts to look good; I left some suggestions on naming, and some other comments; happy to discuss
| "digest": target.Digest, | ||
| "isPseudo": isPseudo, | ||
| }).Debug("pseudo image check failed") | ||
| return nil |
There was a problem hiding this comment.
I notice that here we're returning nil, but for the contentSize, err := img.Size(ctx) error we're logging and continuing; is that intentional?
- Perhaps this line may need a comment why we don't (or can't) continue in this case. And why we can continue if we get a
NotFounderror
There was a problem hiding this comment.
Yes, added a comment. Also the error checking below should also be ignored (so we don't abort the whole list operation just in case there's some issue with one image).
| if isPseudo { | ||
| if img.IsAttestation() { |
There was a problem hiding this comment.
Perhaps not for this PR, but perhaps some of these may be good to extract to a separate function at some point. I think it may make the flow clearer as there's some early returns happening that are easy to miss because they're a bit buried in the code to construct the types.
Basically thinking along the lines of
- determine the
Kind - calling function for
Kindto propagate the relevant data
There was a problem hiding this comment.
Yep, it's a bit complex at this point, but splitting it into functions isn't great either as there's a lot of shared state (totalSize, allChainsIDs, containersCount, best).
I can extract it to a separate struct in a follow up (or later, after we decide to settle for this approach).
There was a problem hiding this comment.
Yup indeed. Perhaps there's not better solution, and definitely OK with me to look at in follow-ups
There was a problem hiding this comment.
I'll definitely try to improve it, but in this case we might need to sacrifice some readability over performance because it's a hot path 😞
9a4749b to
1b685f4
Compare
| // Content is the size (in bytes) of all the locally present | ||
| // content in the content store (e.g. image config, layers) | ||
| // referenced by this manifest and its children. | ||
| // This only includes blobs in the content store. | ||
| Content int64 `json:"Content"` | ||
|
|
||
| // Total is the total size (in bytes) of all the locally present | ||
| // data (both distributable and non-distributable) that's related to | ||
| // this manifest and its children. | ||
| // This equal to the sum of [Content] size AND all the sizes in the | ||
| // [Size] struct present in the Kind-specific data struct. | ||
| // For example, for an image kind (Kind == ManifestKindImage), | ||
| // this would include the size of the image content and unpacked | ||
| // image snapshots ([Size.Content] + [ImageData.Size.Unpacked]). | ||
| Total int64 `json:"Total"` |
There was a problem hiding this comment.
Wondering if these should be nilable in cases where we fail to determine the size? So we can differentiate between 0 and 🤷🏻 .
There was a problem hiding this comment.
Oh, that's a good one; I know we used -1 for other situations, but those were -1 means "we didn't check".
Using omitempty also has its own downsides of course (w.r.t. other tools trying to use the JSON as-is) 🤔
There was a problem hiding this comment.
Would we have cases where "one of these" failed? Or would they more likely "both" fail?
(slightly considering if omitting all of Size would work for that), but .. tricky).
We could also consider adding a Warnings[] array somewhere for non-fatal, but still useful failures
There was a problem hiding this comment.
-1 is a bit meh to me, as it's really easy to get unnoticed, especially if you only add/subtract it.
Yeah I'd be against making it omitempty actually - not sure how other languages could handle it, but in pure JSON I think it's fine to just use explicit null instead of having us use the omitempty?
There was a problem hiding this comment.
Yeah the Warnings would be nice too IMO.
There was a problem hiding this comment.
LOL, we'll just make it a string and put "NaN" in it. Problem solved
thaJeztah
left a comment
There was a problem hiding this comment.
"LGTM"
I left some last few nits/notes, and wasn't sure if you were planning to squash the last touch-up commits.
Otherwise, I think this one should be good to get in from my side ❤️
| ImageManifestSummary: | ||
| description: | | ||
| ImageManifestSummary represents a summary of an image manifest. |
There was a problem hiding this comment.
I think we can either rename the definition here, or add a x-go-name: "ManifestSummary"
There was a problem hiding this comment.
Went with the x-go-name
| Kind: | ||
| description: | | ||
| The kind of the manifest. | ||
| type: "string" | ||
| example: "image" | ||
| enum: | ||
| - "image" | ||
| - "attestation" |
There was a problem hiding this comment.
| Platform: | ||
| $ref: "#/definitions/OCIPlatform" |
There was a problem hiding this comment.
Also fine for a follow-up, and I THINK this is a limitation of the options we have in swagger, but wondering if we can somehow document how this Platform differs from the Descriptor.Platform (one from the descriptor, the other from the image config).
Not sure if it's possible (I don't think swagger accepts combination of description and $ref
There was a problem hiding this comment.
Yup, it's not rendered. However, I think it doesn't seem like it's an error to actually include the description?
There was a problem hiding this comment.
I went ahead and added it regardless of whether it's rendered or not 😅
| properties: | ||
| Platform: |
There was a problem hiding this comment.
Also still contemplating if we want to add image ID (digest of the image-config) somewhere, but that one is probably fine for a follow-up discussion as well.
There was a problem hiding this comment.
I don't think it has any use currently (without exposing the content store to allow to fetch it), so I think we can add it later if needed.
Our version of go-swagger doesn't handle the `omitempty` correctly for the new field. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Use a helper from `ImageManifest` which reads the config instead. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Add `Manifests` field to `ImageSummary` which exposes all image manifests (which includes other blobs using the image media type, like buildkit attestations). There's also a new `manifests` query field that needs to be set in order for the response to contain the new information. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1b685f4 to
050afe1
Compare
Add the
Manifestsfield toImageSummary.CLI initial implementation: docker/cli#4982
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
