Hi Team,
We started to implement the buildkite cache plugin GitHub - buildkite-plugins/cache-buildkite-plugin: 🎩🗄Cache ephemeral files between builds and using the backend S3 for it, since we use elastic-stack CI setup and instances are ephemeral, so we could not use FS backend.
But it gives error when we are using the compression methods. Both tgz and zip gave errors.
We have set this VARs - BUILDKITE_PLUGIN_S3_CACHE_BUCKET
and set AWS profile to interact with the S3 bucket.
Could you help us in identifying the issue? Is there a workaround or fix for this?
We found a git issue already opened for this.
opened 01:18PM - 14 Jul 23 UTC
The S3 backend is unable to sync when using `tgz` compression:
![image](https… ://github.com/buildkite-plugins/cache-buildkite-plugin/assets/2992938/81367bbe-5f14-49e2-a0d8-9386f313f215)
I think this is because the `s3 sync` command does not expect to receive a single file as argument, so it tries to find a directory with the same name instead. Perhaps it should create a temporary directory in /tmp and archive a .tgz file named after the cache key into that temporary directory instead, i.e.
```bash
ACTUAL_PATH="$(mktemp -d)"
"${COMPRESS_COMMAND[@]}" "${ACTUAL_PATH}/${KEY}.tgz" "${CACHE_PATH}"
```
I was able to replicate this on the build agent host manually:
```bash
$ ACTUAL_PATH=$(mktemp)
$ echo $ACTUAL_PATH
/tmp/tmp.WUc3AxyL2d
$ tar czf "$ACTUAL_PATH" .gradle
$ aws s3 sync --endpoint-url "https://data.mina-lang.org" "$ACTUAL_PATH" "s3://buildkite-cache/test-key"
warning: Skipping file /tmp/tmp.WUc3AxyL2d/. File does not exist.
```
The pipeline YAML can be viewed [here](https://codeberg.org/mina-lang/mina/src/commit/e321ed0d8a3a22894910cf708e764f8bbdf67678/.buildkite/pipeline.yml).
You can view a gist of a build log exhibiting this problem [here](https://gist.github.com/DavidGregory084/bf17b49962cf524e7f01ac27eb9f8aba).
One other thing that I noticed in this log is that the second cache post-command hook did not run after the first one failed. Is that expected?
The pipeline step that we used is as
- command: "./scripts/build.sh\n"
label: "build"
agents:
- "queue=frontend"
plugins:
- cache#v0.6.0:
manifest: package-lock.json
backend: s3
compression: tgz
path: node_modules
restore: file
save: file
Hello @surajthakur !
Thanks for the message and hope you are well
Have seen the same case come up before from previous mention - there is a open PR at the moment with our plugin experts to look at tests/get the fix merged in for this case: its a known issue where the s3 sync
command doesn’t expect a single file. Have looped in this callout to that case you’ve linked to, and the team shall look at it shortly.
Much obliged!
James
Hi @james.s
Thanks for the prompt reply. Yeah, I checked the PR raised.
So do you recommend waiting for the PR to be merged?
Should we be waiting for the response on this case?
Thanks for looking into it.
Regards,
Suraj
No worries
I’d suggest so in this case - as there will be work triaged along with testing the actual implementation raised for the hooks changed.
It’s worth keeping tabs on the actual issue on GitHub since that will be closed out with the remedy - but I’ve let our team know of your callout
Thanks @james.s ,
We will keep an eye for updates on this case.
Cheers !!
Hey @surajthakur !
Hope you’ve been well over the weekend
Have let the team know of the PR that was submitted to solve this case and are tracking testing and getting it merged/released accordingly.
Cheers!
James