Add s3 remote cache - #2824
Conversation
|
I'm currently testing this under load @doctolib |
cbbe072 to
ac4ed5f
Compare
ac4ed5f to
f874cd6
Compare
|
Same questions as #2323 .
Why is this 40k lines bigger than the previous PR? Take a look at the CI results as well. cc @sethpollack |
I'm currenlty testing this on my CI.
What do you mean exactly? A dedicated workflow in github which test this? An integration test? Do you have any base I can start from?
Yes.
New version of the aws s3 sdk :(
|
fe68519 to
d856c7d
Compare
I assume testing something like this requires either token credentials or some kind of mock service. Our regular integration tests for things like this are in |
4a5b507 to
d77e1d7
Compare
|
@tonistiigi Can you review?
|
tonistiigi
left a comment
There was a problem hiding this comment.
Add the ./hack/s3_test/run_test.sh invocation to https://github.com/moby/buildkit/blob/master/.github/workflows/build.yml with needs: [base] .
I added a commit that fixes up the Dockerfile and includes the correct buildkit binaries.
It doesn't work for me locally though
Documentation: https://docs.min.io
Finished loading IAM sub-system (took 0.0s of 0.0s to load data).
+ mc alias set myminio http://172.17.0.2:9000 minioadmin minioadmin
mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.
mc: <ERROR> Unable to initialize new alias from the provided credentials. Get "http://172.17.0.2:9000/probe-bucket-sign-tszmiipmum4w/?location=": dial tcp 172.17.0.2:9000: connect: connection refused.
Assuming this works it doesn't actually look as complicated as I would have assumed. You can also consider adding the minio to the main Dockerfile integration-tests stage and adding a regular Go integration test.
FYI @crazy-max
| FROM debian:bullseye-slim | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends wget ca-certificates containerd |
There was a problem hiding this comment.
Why is containerd needed here?
There was a problem hiding this comment.
Buildkit does not start without it
WARN[2022-05-06T08:27:58Z] skipping oci worker, as runc does not exist
WARN[2022-05-06T08:27:58Z] skipping containerd worker, as "/run/containerd/containerd.sock" does not exist
buildkitd: no worker found, rebuild the buildkit daemon?
May be you have a magical option to add to buildkitd -debugaddr 0.0.0.0:8060 :)
| @@ -0,0 +1,4 @@ | |||
| FROM public.ecr.aws/debian/debian:bullseye-slim | |||
|
|
|||
| RUN echo first | |||
There was a problem hiding this comment.
These commands should write a constant plus a random value. See https://github.com/moby/buildkit/blob/master/client/client_test.go#L1410 . Then when you build them export the result to a local directory and check that the unique part has not change. Therefore cache matched.
bf0fb60 to
2cb6501
Compare
Need to think about this later. I don't want an import cycle there. |
Added a commit to add minio to integration tests stage and also use it through linked context in the bake definition for s3 test. I will add another commit to create a new job in our GHA workflow. |
Fixed
I prefer to keep it like this if you dont mind.
I |
@crazy-max just force pushed, sorry may be I drop some stuff. I added something in the build workflow, please feel free to refact. |
Yes just saw that, that's fine. I bring it back.
In the future I think we don't want to rely on scripting but Go integration tests like we do for containerd and dockerd. See https://github.com/moby/buildkit/tree/master/util/testutil/integration |
|
Not linked to this PR but I noticed that when we use linked context in bake a warning from buildx appears: https://github.com/moby/buildkit/runs/6320810388?check_suite_focus=true#step:5:622 Looks linked to docker/buildx#968. There is another one less obvious that seems to appear when using |
178546a to
34e8962
Compare
| } | ||
|
|
||
| func (e *exporter) Config() remotecache.Config { | ||
| return remotecache.Config{} |
There was a problem hiding this comment.
This should return Compression: default
| return config.Prefix + config.BlobsPrefix + dgst.String() | ||
| } | ||
|
|
||
| type cache struct { |
There was a problem hiding this comment.
Calling this cache seems kind of confusing. It's more like s3Client
| } | ||
|
|
||
| func (c *cache) getManifest(key string, config *v1.CacheConfig) (bool, error) { | ||
| fmt.Printf("Start downloading s3://%s/%s\n", c.config.Bucket, key) |
There was a problem hiding this comment.
Writing to stdout is not allowed in here. If you want debug logs then you need to write them to the context logger.
| } | ||
|
|
||
| func isNotFound(err error) bool { | ||
| awsErr, ok := err.(awserr.Error) |
| FROM public.ecr.aws/debian/debian:bullseye-slim | ||
|
|
||
| RUN cat /dev/urandom | head -c 100 | sha256sum > unique_first | ||
| RUN cat /dev/urandom | head -c 100 | sha256sum > unique_second No newline at end of file |
There was a problem hiding this comment.
Add a another stage in here
FROM scratch
COPY --link --from=build /unique_first /
COPY --link --from=build /unique_second /
And in the test add --output destdir . After cache import the contents of the files need to remain the same.
a971027 to
ede8d29
Compare
tonistiigi
left a comment
There was a problem hiding this comment.
LGTM but try to squash the commits a bit. It doesn't need to be a single commit but we should avoid commits that just say "fixes" or "code review". Maybe squash these 2 with the first commit. The others can remain as they are.
| func news3Client(config Config) (*s3Client, error) { | ||
| s, err := sess.NewSession(&aws.Config{Region: &config.Region, Endpoint: &config.EndpointURL, S3ForcePathStyle: &config.S3ForcePathStyle}) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create session: %w", err) |
There was a problem hiding this comment.
Use errors.Errorf always for stacktraces
3bb72f7 to
86c98b4
Compare
|
@tonistiigi I squashed everything and moved to aws-sdk-go-v2. Ready for review :) |
| @@ -0,0 +1,7 @@ | |||
| #!/bin/sh -ex | |||
There was a problem hiding this comment.
I'm using it to launch the test locally.
There was a problem hiding this comment.
If we have a helper script we should call it in the CI. Otherwise nobody notices if it breaks or starts to behave differently than CI invocations.
349c24c to
e0b54a4
Compare
| google.golang.org/grpc v1.45.0 | ||
| ) | ||
|
|
||
| require github.com/aws/aws-sdk-go-v2/config v1.15.5 |
There was a problem hiding this comment.
should be moved in the previous require block
There was a problem hiding this comment.
Fixed. I should do something wrong when I update mod / vendor :(
Signed-off-by: Bertrand Paquet <bertrand.paquet@gmail.com>
There was a problem hiding this comment.
LGTM
in a follow-up we should think about proper integration tests in testutil but might need to split first as suggested by @tonistiigi in #2734 (comment)
also README starts to be quite huge. wonder if we should not move some sections in dedicated pages under ./docs like the cache exporters.
|
@tonistiigi Can I send support GCS as well? |
|
I’m using it to run the test locally.
…On Fri 13 May 2022 at 00:03, Tõnis Tiigi ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In hack/s3_test/run_test.sh
<#2824 (comment)>:
> @@ -0,0 +1,7 @@
+#!/bin/sh -ex
This file looks unused now
—
Reply to this email directly, view it on GitHub
<#2824 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACSJXKMF2JOLXFTVW7POXTVJV53HANCNFSM5UJLRGCA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Largely inspired from #2323