-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Feat: send additional build contexts as tar files for remote builds #26628
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
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.
Not a full review, but reading into memory does not seem viable to me.
Have a look at ManifestModify() and the bindings manifests Modify() functions which AFAICT to such a multipart request without reading all into memory
Git Repositories: cloned locally then sent as a tar
URLs/archives: downloaded locally then sent as a tar
It would be best if just the server downloads them instead of the client, sending them as tar via the API just sounds slower.
7ea602e
to
b2db9e2
Compare
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
b2db9e2
to
71f5764
Compare
5b62920
to
d56b2a1
Compare
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.
Some unnecessary duplication of archive/extracting logic on both ends, probably still have an issue where the top-level directory of an additional build context has a different timestamp between otherwise-identical build requests made at different times.
I think for me this goes a bit to much into the breaking chnage territory, if caching gets broken on remote then this is a bit problematic. Also the copy now makes it much slower compared to the local file thing before. I think this PR is overall the right thing to do but I think I would prefer for this to wait for 6.0. Or maybe this is something where the work @Honny1 is doing with a local build API could help here. Where we can have the local and remote way working so users could take advantage of either one. |
Yes, a |
pkg/machine/e2e/basic_test.go
Outdated
@@ -249,8 +249,8 @@ var _ = Describe("run basic podman commands", func() { | |||
}) | |||
|
|||
It("podman build contexts", func() { | |||
Skip("Waiting for VM images with Podman > 5.5.2 for multipart build context support") |
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 is all of the sudden skipping for all tests, I would think this test must still pass. IF this doesn't pass it means we break backwards compatibility.
For the qemu skip you can switch the test to say unskip when machine image contain podman with this patch.
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.
After a quick review of the code, I believe it would be more straightforward if additional build contexts were handled within the query, and the files to be transferred were part of the incoming tar. This could simplify the code significantly by removing the need to parse multipart/form-data
.
e9f7827
to
3ccd11a
Compare
Also if we add a new content type then the new format must be document in our swagger file in pkg/api/server/register_images.go as well. |
buildDir := filepath.Join(anchorDir, "build") | ||
err := os.Mkdir(buildDir, 0o700) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
err = archive.Untar(r.Body, buildDir, nil) | ||
err = archive.Untar(r, buildDir, 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.
Any reason this isn't chrootarchive.Untar()
?
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.
That function already had it like that
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.
Sure, but why?
3ccd11a
to
84d6ce0
Compare
84d6ce0
to
a3778e8
Compare
a3778e8
to
6c04df1
Compare
pkg/api/server/register_images.go
Outdated
// Additional build contexts for builds that require more than one context. | ||
// We send both URL and image links through query parameters where we then setup the additional build contexts | ||
// struct. Local additional build contexts are sent as tar files via multipart/form-data. | ||
// (As of version 5.6.0) |
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 is the compat endpoint. Do other clients submit this information this way?
// Additional build contexts for builds that require more than one context. | ||
// We send both URL and image links through query parameters where we then setup the additional build contexts | ||
// struct. Local additional build contexts are sent as tar files via multipart/form-data. | ||
// (As of version 5.6.0) |
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.
I don't think you need to mention data types used by the implementation, which a client wouldn't care about. A client would care about how they're expected to describe contexts that are URLs or images, so it would probably be good to describe what the strings should look like here.
1c4f355
to
0467ad7
Compare
Fixed the --build-context flag to properly send files for remote builds. Previously only the main context was sent over as a tar while additional contexts were passed as local paths and this would cause builds to fail since the files wouldn't exist. New changes modifies the Build API to use multipart HTTP requests allowing multiple build contexts to be used. Each additional context is packaged and transferred based on its type: - Local Directories: Sent as tar archives - Git Repositories: link sent to the server where its then cloned - Container Images: Image reference sent to the server, it then pulls the image there - URLs/archives: URL sent to the server, which handles the download Fixes: containers#23433 Signed-off-by: Joshua Arrevillaga <[email protected]>
0467ad7
to
73f3e98
Compare
LGTM |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 2004joshua, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
12b7a33
into
containers:main
Fixed the --build-context flag to properly send files for remote builds. Previously only the main context was sent over as a tar while additional contexts were passed as local paths and this would cause builds to fail since the files wouldn't exist.
New changes modifies the Build API to use multipart HTTP requests allowing multiple build contexts to be sent as tar files. Each additional context is packaged and transferred based on its type:
Version check is in place to make sure that the server is updated to at least the upcoming 5.6.0 update or else the fix wont be usable.
Fixes: #23433
Does this PR introduce a user-facing change?