LCOW (and generic): Add Supported-Platforms to _ping API endpoint#34628
LCOW (and generic): Add Supported-Platforms to _ping API endpoint#34628lowenna wants to merge 1 commit intomoby:masterfrom
Conversation
pkg/system/lcow.go
Outdated
There was a problem hiding this comment.
since this is outside of the API layer, this should return []Platform , right?
And the api layer can transform that into a comma separated list?
There was a problem hiding this comment.
hmm, I need to look into where the Has-Experimental header is added, I would expect this in the same place.
There was a problem hiding this comment.
That's set in WrapHandler in the middleware and does it for every request by the look of it, rather than just on _ping.
40ca378 to
8fd5a84
Compare
|
@dnephin. Updated (but not the location of where it's set - see my comment above). I was being silly - I JSON encoded it instead to preserve structure. And used the OCI image-spec structure to match what @stevvooe has been working on in https://github.com/containerd/containerd/pull/1403/files for example. So it now will return something like: |
Signed-off-by: John Howard <jhoward@microsoft.com>
8fd5a84 to
a1c7695
Compare
|
Thinking a little more - maybe Input welcome 😄 |
|
@tonistiigi too. |
dnephin
left a comment
There was a problem hiding this comment.
I think Supported-Platform should be ok. For multi-stage builds that support different platforms the Dockerfile would need a FROM --platform. The client doesn't really parse the Dockerfile so it shouldn't refuse to build something because of that header.
| description: "If the server is running with experimental mode enabled" | ||
| Supported-Platforms: | ||
| type: "string" | ||
| description: "JSON encoded list of supported platforms" |
There was a problem hiding this comment.
Personally I'm not a fan of JSON encoded HTTP headers/query values. I liked the comma separated list. If I'm alone on this I can live with the JSON.
There was a problem hiding this comment.
I can go either way. I'm not sure we have other examples of passing as JSON encoded, but we certainly use Base64 encoded headers (such as registry auth). I kind of liked the fidelity using a JSON structure, and no need to do string-conversion routines.
|
What's the use case for this? The linked issue talks about detecting if a flag is supported but this can be done with a version identifier like for any other new feature. |
|
@tonistiigi It's based on #34617 (comment), the second part by @dnephin: "The CLI should hide the --platform flag when it's connecting to any daemon that doesn't support multi-platform. This is similar to how we handle experimental features, and features that exist in a newer version of the API (API downgrading). The daemon should return a Is-Multi-Platform header on _ping so the cli can hide these flags." |
|
Problem with hiding the |
Not true. Hidden doesn't mean it's an error to provide it, it just doesn't show up in |
|
That's not how the experimental and version annotations work that were used as an example. Why is this case special? We have tens of flags that are platform specific and even more that depend on a feature being available on a node. They are validated during the request, not with a ping. |
It is how they are implemented: https://github.com/docker/cli/blob/d861a1c3ddd794cd64d6c2efb722d7d33391ead7/cmd/docker/docker.go#L211-L237 . We hide them, we don't remove the flag entirely. However, apparently we also do another check and error out here (https://github.com/docker/cli/blob/d861a1c3ddd794cd64d6c2efb722d7d33391ead7/cmd/docker/docker.go#L245-L271). This is probably because in these cases the daemon will either 1) completely ignore the flag, or 2) report 404 if the API endpoint doesn't exist. In these cases it's better to offer the user an error on the client side because the API doesn't do the right thing. In the case of
This is a problem we've already started to fix. From the linked code you can see we have started to hide features by API OSType. |
|
Long out-of-date. Closing as I am no longer working in this area. |
Signed-off-by: John Howard jhoward@microsoft.com
This is part of the LCOW discussion issue, specifically for #34617 (comment). It adds an HTTP header to the _ping API endpoint so that a client can determine whether the daemon is multi-platform capable, and the list of possible values. As HTTP headers can't be structured, it passes this as a string.
For a Linux daemon, it would return something like
Supported-Platforms: linux/amd64. For a dual-mode LCOW/WCOW daemon on Windows, it would returnSupported-Platforms: windows/amd64,linux/amd64.@dnephin @johnstep
EDIT: Updated to use JSON encode the OCI Image-Spec platform structure instead of a comma-separated list.