-
Notifications
You must be signed in to change notification settings - Fork 18.9k
API: add Platform (OS and Architecture) to /containers/json #49407
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
Conversation
|
Ah, right, I need to refresh my memory as I recall there was some back and forth on doing this and I think some considered that it was part of the image info, but it's a long time since I worked on #42464 |
|
(i.e. ISTR there was some suggestion to include the image descriptor in the response or something along those lines ... but I need to dig really deep in memory 🤣) |
|
I did need to update the original PR a bit, but it was fewer code changes rather than more. The daemon didn't require any change because the platform had been added as a parameter at some point so it was already present. |
vvoland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, wondering if we should consider doing the same as we do for container inspect (/containers/.../json), where we return the full image manifest descriptor with the Platform field set.
See: #48855
|
@vvoland I'd say yes, but the |
|
Yes, so that would actually solve that issue. If we exposed the whole image manifest descriptor like we did in container inspect: moby/api/types/container/container.go Lines 175 to 176 in 44ed306
the platform would also be a part of that descriptor: moby/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go Lines 45 to 46 in e3feb05
moby/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go Lines 19 to 46 in e3feb05
|
c1ae171 to
626a3f0
Compare
| if versions.LessThan(version, "1.48") { | ||
| // ImageManifestDescriptor information was added in API 1.48 | ||
| for _, c := range systemDiskUsage.Containers { | ||
| c.ImageManifestDescriptor = nil | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should include that in the system disk usage at all 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. ISTR that one was the horrible type that was reused "for convenience", but keeps popping up?
api/types/container/container.go
Outdated
| Names []string | ||
| Image string | ||
| ImageID string | ||
| ImageManifestDescriptor *ocispec.Descriptor `json:",omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! Before I blame myself; we've been very lax on specifying the intended casing of fields in JSON (depending on "whatever Go makes of it); this has resulted in inconsistencies where the Swagger documented the wrong casing (the Id one is a good example of that, where we had to later adjust the case to what it happened to be). Go itself treats JSON case-insensitive, but not all languages do (and ISTR Go is working on a "v2" JSON package to allow case-sensitivity).
Probably good to add an explicit json:"ImageManifestDescriptor,omitempty" (at least for new fields; we should also tackle existing fields at some point)
28dcca1 to
921ed17
Compare
neersighted
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with CI passing.
Adds platform information to containers (for `docker ps`). Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
921ed17 to
927e07e
Compare
|
I've updated the test to only run when a multi-platform store is in use. I copied this from |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| snapshot.NetworkSettings = &container.NetworkSettingsSummary{Networks: networks} | ||
|
|
||
| if ctr.ImageManifest != nil && ctr.ImageManifest.Platform == nil { | ||
| ctr.ImageManifest.Platform = &ctr.ImagePlatform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctr is supposed to be immutable, we shouldn't patch it in ctr directly.
This should be patched in snapshot.Summary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @jsternberg
Adds platform information to containers (for
docker ps).- What I did
Added the platform to the
container.Summarystruct so it could be returned in/containers/json.- How I did it
Adapted this PR for the current master and upcoming api version: #42464
As mentioned in the original PR, there's still some follow up. I'm copying and pasting that message here.
The last one seems to be a potentially big issue with the name. The
Platformis used instead of the nameOS, butPlatformin that API is the same as the OS.- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)