-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix JFROG Artifactory Compatibility #383
Conversation
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.
This LGTM, thank you for the investigation and fix. Is there any way we can detect from the error response during the push that
a) the registry is JFrog (and so we might suggest setting the new flag in the user's project file/props)
b) the error is informative enough to suggest doing the same irrespective of registry?
We may need to have a new docs section for specific guidance for registries.
I would like to add an explicit test for jfrog in baronfel/sdk-container-demo, but it doesn't look like there's a image or a public free service that I can use. Do you have any pointers there?
The error is rather cryptic but yes it would be possible to detect JFrog Artifactory. They have a special HTTP Header in their API responses we could use: If the manifest upload fails with such a "manifest invalid" error, and we detect a JFrog/Artifactory header, we could report an additional info.
Unfortunately not really. It is partially a bug and/or a very strict validation of layers against history items. The error is always a "manifest invalid" which could also have other causes. The specific thing about history was tricky to find out.
There is a JFrog Artifactory OSS Docker image you could use.
|
So an alternative here would be to try and 'fix' the history in our generated images, creating a history entry for any empty layers that don't have one? |
In theory it could be an approach/attempt to create a history which satisfies the JFrog Artifactory checks. But there is not really a formal specification behind this it seems. So we would need to rely on "decompiling" and finding out the current implementation and hope it will not change. 😓 |
@Danielku15 there is some precedent here - here's how jib handles this mismatch for example(relevant issue discussion) - I'd really like to try that before adding a new flag that users have to remember. |
@baronfel I will give it a try and see how it goes. I think handling too many history entries and removing some shouldn't be needed. Then already the push of the base layer should fail and that cannot be solved by sdk-container-builds anyhow. What do you think? |
Made the change and tested it against our Artifactory instance. I can confirm that matching the number of non empty_layer history entries and layers must match to make Artifactory accept it. |
I had to convert this PR back into a draft. I updated our internal build of sdk-container-builds to the latest state of this branch. While the whole build and push works, pulling back the image currently fails with a:
I have to dig into this topic first. I am not sure at this point if this problem still relates to Artifactory or is a general problem with the layer creation. **Edit: ** It seems that Artifactory handles the Content-Range header wrong on chunked uploads in the way we send it. In the patch response we always receive |
@baronfel It seems chunking is not supported by Artifactory correctly. Most tools are not trying to upload things in smaller chunks but it might be rather a recovery mechanism. My proposal would be to maybe fully remove the chunked upload and upload only a single full chunk in all cases. GCR already has problems hence this code exists. This might also be a root cause for #315 Upload in many small chunks can cost quite some time. Just uploading it as a whole is likely a lot faster (increasing buffer size might be boost further). Here my analysis to justify that the removal of chunked upload would be a good choice: GoogleContainerTools/jib (12.6k stars) https://github.com/containers/image (733 stars) https://github.com/devcontainers/cli/ (635 stars) https://github.com/openSUSE/openSUSE-release-tools (50 stars) Original Docker CLI
|
I talked with the team and we'd accept a change in default for chunking from enabled-by-default to disabled-by-default 👍 Once that change happens I can test it over on baronfel/sdk-container-demo to make sure we don't regress on any of the other providers. |
Made the change by adding a new setting hidden behind a environment variable to control the chunked upload. |
Thanks for adding that flag! That seems to work for most registries (including a JFrog instance I stood up in the cloud on trial), but GitHub is failing on the 'finalize' call: https://github.com/baronfel/sdk-container-demo/actions/runs/4407492891/jobs/7721270965. I don't see what would cause this initially, though. |
No clue at this point what could cause this 🤔 . I will have to debug that registry locally to see what's going on there. The only thing I see from reading the code is that we maybe not dispose all |
@baronfel Can you please try to re-run the job? I tested some things locally and cannot directly reproduce this error locally and was able to push a image to GHCR. I could see a different error during my tests I had to workaround: For some reason, on the blob upload call, ghcr.io does not respond with a 401 Unauthorized but just drops the TCP connection. I locally made a small workaround to get the auth info filled directly and the push succeeded fine. I will open a different issue for this authentication handler "problem". |
Here's job re-run number 3 - still the same error. We have a GitHub request ID this time due to the logging I added so I've reached out to our contacts on GitHub Packages to see if they have any more detailed information. |
@Danielku15 I added you and the other maintainers of this repo as collaborators on baronfel/sdk-container-demo, so you should be able to more easily test iterations of changes to this repo via the GitHub Actions using the secrets I've already provisioned. |
@baronfel Used the main branch package and can confirm that it is already broken on
I haven't checked yet what could cause it. Things are quite busy for me these days but I try to catch up on this topic soon. |
I confirm your results (which is quite confusing). I'll merge this and we can continue to dig in. |
Resolves #382
This PR enables compatibility with JFROG Artifactory docker registries to push images.
There are two compat issues:
Accept
HTTP header is validated on certain API calls which leads to failed pushes. I changed to only provide the headers on pull/load related API calls.I tested the changes against our company internal Artifactory instance by adapting the
EndToEndTests.ApiEndToEndWithRegistryPushAndPull
and I can successfully push against our registry: