-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add s3 remote cache #2824
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?
|
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.
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
hack/s3_test/Dockerfile
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is containerd needed here?
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.
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
:)
hack/s3_test/test1/Dockerfile
Outdated
@@ -0,0 +1,4 @@ | |||
FROM public.ecr.aws/debian/debian:bullseye-slim | |||
|
|||
RUN echo first |
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.
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.
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.
Done
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
cache/remotecache/s3/s3.go
Outdated
} | ||
|
||
func (e *exporter) Config() remotecache.Config { | ||
return remotecache.Config{} |
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 should return Compression: default
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.
done
cache/remotecache/s3/s3.go
Outdated
return config.Prefix + config.BlobsPrefix + dgst.String() | ||
} | ||
|
||
type cache struct { |
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.
Calling this cache
seems kind of confusing. It's more like s3Client
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.
Done
cache/remotecache/s3/s3.go
Outdated
} | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing to stdout is not allowed in here. If you want debug logs then you need to write them to the context logger.
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.
removed all debug
cache/remotecache/s3/s3.go
Outdated
} | ||
|
||
func isNotFound(err error) bool { | ||
awsErr, ok := err.(awserr.Error) |
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 should use errors.As
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.
Done
hack/s3_test/test1/Dockerfile
Outdated
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 |
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.
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.
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.
Done
a971027
to
ede8d29
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.
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.
cache/remotecache/s3/s3.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file looks unused now
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'm using it to launch the test locally.
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.
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.
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.
Used it in the CI
349c24c
to
e0b54a4
Compare
go.mod
Outdated
@@ -76,7 +80,22 @@ require ( | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be moved in the previous require block
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.
Fixed. I should do something wrong when I update mod / vendor :(
Signed-off-by: Bertrand Paquet <[email protected]>
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
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