From ca840f2687b72f2044c2df67503fd60884f72536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 31 Oct 2024 09:08:26 +0100 Subject: [PATCH] ansible: use rclone instead of aws CLI Use rclone to upload assets to Cloudflare as it is more reliable. Refs: https://github.com/nodejs/build/issues/3508 --- ansible/www-standalone/tasks/cloufdflare.yaml | 45 ------------------- .../www-standalone/tools/promote/_resha.sh | 16 ++----- ansible/www-standalone/tools/promote/settings | 6 +-- .../tools/promote/upload_to_cloudflare.sh | 26 +++-------- 4 files changed, 12 insertions(+), 81 deletions(-) delete mode 100644 ansible/www-standalone/tasks/cloufdflare.yaml diff --git a/ansible/www-standalone/tasks/cloufdflare.yaml b/ansible/www-standalone/tasks/cloufdflare.yaml deleted file mode 100644 index f5dc56523..000000000 --- a/ansible/www-standalone/tasks/cloufdflare.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- - -- name: create .aws directory - ansible.builtin.file: - dest: "dist/.aws" - owner: dist - group: dist - state: directory - -- name: copy credentials to deploy release artifacts - ansible.builtin.copy: - content: "{{ secrets.worker_credentials }}" - dest: "dist/.aws/credentials" - owner: dist - group: dist - -- name: write worker_config - ansible.builtin.copy: - dest: "dist/.aws/config" - src: "{{ role_path }}/files/worker_config" - owner: dist - group: dist - - -# https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html -- name: Download awscliv2 installer - unarchive: - src: "https://awscli.amazonaws.com/awscli-exe-linux-{{ ansible_architecture }}.zip" - dest: "/tmp" - remote_src: true - creates: '/tmp/aws' - mode: 0755 - -- name: Run awscliv2 installer - command: - args: - cmd: "/tmp/aws/install" - creates: /usr/local/bin/aws - become: true - register: aws_install - -- name: "Show awscliv2 installer output" - debug: - var: aws_install - verbosity: 2 diff --git a/ansible/www-standalone/tools/promote/_resha.sh b/ansible/www-standalone/tools/promote/_resha.sh index b450e4d7a..20e985fff 100755 --- a/ansible/www-standalone/tools/promote/_resha.sh +++ b/ansible/www-standalone/tools/promote/_resha.sh @@ -34,16 +34,6 @@ if [ -z ${staging_bucket+x} ]; then exit 1 fi -if [ -z ${cloudflare_endpoint+x} ]; then - echo "\$cloudflare_endpoint is not set" - exit 1 -fi - -if [ -z ${cloudflare_profile+x} ]; then - echo "\$cloudflare_profile is not set" - exit 1 -fi - (cd "${dstdir}/${version}" && shasum -a256 $(ls node* openssl* iojs* win-*/* x64/* 2> /dev/null) > SHASUMS256.txt) || exit 1 if [[ $version =~ ^v[0] ]]; then (cd "${dstdir}/${version}" && shasum $(ls node* openssl* x64/* 2> /dev/null) > SHASUMS.txt) || exit 1 @@ -54,6 +44,6 @@ find "${dstdir}/${version}" -type f -exec chmod 644 '{}' \; find "${dstdir}/${version}" -type d -exec chmod 755 '{}' \; relativedir=${dstdir/$dist_rootdir/"$site/"} -aws s3 cp ${dstdir}/index.json $staging_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null -aws s3 cp ${dstdir}/index.tab $staging_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null -aws s3 cp ${dstdir}/${version}/SHASUMS256.txt $staging_bucket/$relativedir/${version}/SHASUMS256.txt --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile > /dev/null +rclone copyto ${dstdir}/index.json $staging_bucket/$relativedir/index.json > /dev/null +rclone copyto ${dstdir}/index.tab $staging_bucket/$relativedir/index.tab > /dev/null +rclone copyto ${dstdir}/${version}/SHASUMS256.txt $staging_bucket/$relativedir/${version}/SHASUMS256.txt > /dev/null diff --git a/ansible/www-standalone/tools/promote/settings b/ansible/www-standalone/tools/promote/settings index 24342c1ce..e149fda51 100755 --- a/ansible/www-standalone/tools/promote/settings +++ b/ansible/www-standalone/tools/promote/settings @@ -37,7 +37,5 @@ chakracore_release_srcdir=${staging_rootdir}chakracore-release chakracore_release_dstdir=${dist_rootdir}chakracore-release chakracore_release_dirmatch=.* -cloudflare_endpoint=https://07be8d2fbc940503ca1be344714cb0d1.r2.cloudflarestorage.com -cloudflare_profile=worker -staging_bucket=s3://dist-staging -dist_bucket=s3://dist-prod +prod_bucket=r2:dist-prod +staging_bucket=r2:dist-staging diff --git a/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh b/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh index bc2add9e6..0c2d981e9 100755 --- a/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh +++ b/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh @@ -22,30 +22,18 @@ if [ -z ${dist_rootdir+x} ]; then echo "\$dist_rootdir is not set" exit 1 fi -if [ -z ${staging_bucket+x} ]; then - echo "\$staging_bucket is not set" - exit 1 -fi -if [ -z ${dist_bucket+x} ]; then - echo "\$dist_bucket is not set" +if [ -z ${prod_bucket+x} ]; then + echo "\$prod_bucket is not set" exit 1 fi -if [ -z ${cloudflare_endpoint+x} ]; then - echo "\$cloudflare_endpoint is not set" - exit 1 -fi -if [ -z ${cloudflare_profile+x} ]; then - echo "\$cloudflare_profile is not set" +if [ -z ${staging_bucket+x} ]; then + echo "\$staging_bucket is not set" exit 1 fi relativedir=${dstdir/$dist_rootdir/"$site/"} tmpversion=$2 -# Due to R2 limitations, `aws s3 cp` and `aws s3 sync` only succeed in copying -# different sets of files across. Fortunately the sets are disjoint, so running -# both commands (ignoring errors) will copy all the files across. -aws s3 cp $staging_bucket/$relativedir/$tmpversion/ $dist_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --recursive --no-follow-symlinks --copy-props none || true -aws s3 sync $staging_bucket/$relativedir/$tmpversion/ $dist_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --no-follow-symlinks || true -aws s3 cp $staging_bucket/$relativedir/index.json $dist_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile -aws s3 cp $staging_bucket/$relativedir/index.tab $dist_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile +rclone copy $staging_bucket/$relativedir/$tmpversion/ $prod_bucket/$relativedir/$tmpversion/ +rclone copyto $staging_bucket/$relativedir/index.json $prod_bucket/$relativedir/index.json +rclone copyto $staging_bucket/$relativedir/index.tab $prod_bucket/$relativedir/index.tab