api: implement compat distribution inspect endpoint#28358
Conversation
df2ff09 to
12e4664
Compare
12e4664 to
8dd8fed
Compare
| func DistributionInspect(w http.ResponseWriter, r *http.Request) { | ||
| runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) | ||
| imageName := utils.GetName(r) | ||
| if _, err := reference.ParseNormalizedNamed(imageName); err != nil { |
There was a problem hiding this comment.
I believe this check is redundant with the check on row 42.
| } | ||
|
|
||
| var latestErr error | ||
| appendErr := func(e error) { |
| t GET "/distribution/quay.io/idonotexist/idonotexist:dummy/json" 401 | ||
|
|
||
| # Exercise the single-manifest path using a digest from the multi-arch test image. | ||
| single_manifest_digest=sha256:6953980e46925f8ac2c09fc7ecf9f353c2cac49f87e7e60ed78287d55a14c296 |
There was a problem hiding this comment.
I am not sure about hardcoding the manifest digest.
| utils.InternalServerError(w, latestErr) | ||
| } | ||
|
|
||
| func distributionInspectFromManifest(ctx context.Context, src types.ImageSource, named reference.Named, manifestBytes []byte, manifestType string) (dockerRegistry.DistributionInspect, error) { |
There was a problem hiding this comment.
I think this function can be simplified with things from container-libs. Please check that repository; there are definitely things that can help simplify it.
|
thanks for the comments @Honny1, will review and implement the changes. |
da4dd25 to
d2d374f
Compare
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
3 similar comments
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
@mtrmac mind adding this to your list of things to review at your convience ? |
56bd7e5 to
9454b2a
Compare
mtrmac
left a comment
There was a problem hiding this comment.
(I didn’t study the Podman API integration in detail, looking mostly at the c/image parts.)
| runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) | ||
| imageName := utils.GetName(r) | ||
|
|
||
| normalizedImageName, err := utils.NormalizeToDockerHub(r, imageName) |
There was a problem hiding this comment.
This looks up images in local storage, and changes the results based on that. Do we want that?!
| sys := runtime.SystemContext() | ||
| sys.AuthFilePath = authfile | ||
| sys.DockerAuthConfig = authConf | ||
| if err := utils.PossiblyEnforceDockerHub(r, sys); err != nil { |
There was a problem hiding this comment.
Does this do anything after NormalizeToDockerHub?
There was a problem hiding this comment.
no effect, removed.
| } | ||
|
|
||
| var registryErrCode errcode.ErrorCoder | ||
| if errors.As(combinedErr, ®istryErrCode) { |
There was a problem hiding this comment.
(This is pretty inaccurate but I also don’t have any better ideas.)
There was a problem hiding this comment.
There was a problem hiding this comment.
It’s not exactly the same situation — Moby collects errors per mirror (where the last one is the primary registry), we collect errors per short name candidate (where the first one is the one we prefer).
By “pretty inaccurate” I meant that we have no good way to report “authentication error or not” when we resolve to multiple short name candidates, and the answers may differ for different candidates.
[Maybe we don’t want the short name resolution and all this goes away? I don’t know.]
I think it makes more sense to report errors for all of the short name candidates (regardless of what HTTP status we use, the text is more useful if it contains everything).
There was a problem hiding this comment.
changed back to reporting all candidate errors
f9c45c1 to
03b2ea2
Compare
| sys.AuthFilePath = authfile | ||
| sys.DockerAuthConfig = authConf | ||
|
|
||
| resolved, err := shortnames.Resolve(sys, named.String()) |
There was a problem hiding this comment.
ParseNormalizedNamed().String() is never a short name.
I don’t know what we want to do here (compare earlier use of utils.NormalizeToDockerHub), but this specific combination doesn’t make sense.
(I think being consistent with the rest of the handlers/compat’s handling would be preferable, but I’ll leave that to experts.)
There was a problem hiding this comment.
(I think being consistent with the rest of the
handlers/compat’s handling would be preferable, but I’ll leave that to experts.)
I think we should match other compat handlers Docker Hub normalization behavior. Becuase this API is for compatibility with Docker.
There was a problem hiding this comment.
ok, I've changed it back to use utils.NormalizeToDockerHub and corresponding reference.ParseNormalizedNamed
There was a problem hiding this comment.
I think we should match other compat handlers Docker Hub normalization behavior. Becuase this API is for compatibility with Docker.
Then we are back to #28358 (comment) . Is that desirable? OTOH, looking now, pulls using the compat API also do this, and that might be a pretty strong reason to have that behavior for remote inspect as well. I’ll leave that to Podman maintainers.
| } | ||
|
|
||
| var registryErrCode errcode.ErrorCoder | ||
| if errors.As(combinedErr, ®istryErrCode) { |
There was a problem hiding this comment.
It’s not exactly the same situation — Moby collects errors per mirror (where the last one is the primary registry), we collect errors per short name candidate (where the first one is the one we prefer).
By “pretty inaccurate” I meant that we have no good way to report “authentication error or not” when we resolve to multiple short name candidates, and the answers may differ for different candidates.
[Maybe we don’t want the short name resolution and all this goes away? I don’t know.]
I think it makes more sense to report errors for all of the short name candidates (regardless of what HTTP status we use, the text is more useful if it contains everything).
| sys.AuthFilePath = authfile | ||
| sys.DockerAuthConfig = authConf | ||
|
|
||
| resolved, err := shortnames.Resolve(sys, named.String()) |
There was a problem hiding this comment.
(I think being consistent with the rest of the
handlers/compat’s handling would be preferable, but I’ll leave that to experts.)
I think we should match other compat handlers Docker Hub normalization behavior. Becuase this API is for compatibility with Docker.
6c3c566 to
dfdbc40
Compare
|
PTAL @containers/podman-maintainers |
| for _, candidate := range resolved.PullCandidates { | ||
| inspect, err := inspectCandidate(r.Context(), sys, candidate.Value) | ||
| if err != nil { | ||
| merr = multierror.Append(merr, err) |
There was a problem hiding this comment.
If we report all errors, the individual ones must be annotated with candidate.Value.String(), otherwise users would have no idea how the failures and the registries correspond.
There was a problem hiding this comment.
thanks, i've added the annotation using the format candidate.Value.String(): error
dfdbc40 to
1018613
Compare
|
@aaron-ang, can you please rebase on main? Thanks |
Signed-off-by: Aaron Ang <aaron.angyd@gmail.com>
1018613 to
0a72f99
Compare
|
Cockpit tests failed for commit 0a72f99. @martinpitt, @jelly, @mvollmer please check. |
|
Hi there, could you let me know if I need to rebase or fix my tests? I can't tell if the CI failures are due to my changes. Thanks! |
|
The remaining two are allowed failures, this is actually merge ready now |
mheon
left a comment
There was a problem hiding this comment.
LGTM
@containers/podman-maintainers PTAL
Fixes #17726.
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?