Skip to content
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

promote: add check_r2_assets tool #3977

Merged
merged 1 commit into from
Dec 11, 2024
Merged

promote: add check_r2_assets tool #3977

merged 1 commit into from
Dec 11, 2024

Conversation

richardlau
Copy link
Member

Add tool and tests for checking if assets on R2 look ready for promotion. Relies on rclone being available -- there's a test for the case where it is not.

The new tool is based on existing check_assets.js but:

  • Written in ESM.
  • Uses built-in Set objects instead of emulating sets with Arrays.
  • Always assumes an asset file exists. check_assets.js has some fallback logic, but it's not straightforward and nowadays we can consider a missing asset file to be a process failure.
  • Reflects that .done files are not used for R2 (basically they don't exist so no handling logic). Also note that for R2, promotion is a copy and not a move so after a partial promotion subsequent checks will result in overwrite warnings for files previously promoted.
  • SHASUMS256.txt can end up in the staging directory. Ignore for the staging directory as check_assets.js does for dist. (The shasums are generated by later parts of the release process.)

Fixes: #3958


FYI @nodejs/releasers

Comment on lines +27 to +30
relative_srcdir=${srcdir/$staging_rootdir/"$site/"}
relative_dstdir=${dstdir/$dist_rootdir/"$site/"}

node --no-warnings /home/staging/tools/promote/check_r2_assets.mjs $staging_bucket/$relative_srcdir/$2 $prod_bucket/$relative_dstdir/$2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@targos FYI I have deployed this PR onto www and am fairly confident it should work (without doing an actual release). If this does interfere with nodejs/node#56119 then commenting out these additional lines should restore the old behaviour (i.e. check the DO droplet only).

@richardlau
Copy link
Member Author

  • Reflects that .done files are not used for R2 (basically they don't exist so no handling logic). Also note that for R2, promotion is a copy and not a move so after a partial promotion subsequent checks will result in overwrite warnings for files previously promoted.

To illustrate the difference:
Check on already fully promoted release on DO droplet:

$ node --no-warnings /home/staging/tools/promote/check_assets.js /home/staging/nodejs/release/v22.12.0 /home/dist/nodejs/release/v22.12.0
... Checking assets
... Expecting a total of 47 assets for v22.x
... 0 assets waiting in staging
... 47 assets already promoted
 ✓  Complete set of expected assets in place for v22.x
$

Equivalent check on R2:

$ node --no-warnings /home/staging/tools/promote/check_r2_assets.mjs r2:dist-staging/nodejs/release/v22.12.0 r2:dist-prod/nodejs/release/v22.12.0
... Checking R2 assets
... Expecting a total of 47 assets for v22.x
... 47 assets waiting in R2 staging
 ⚠  47 assets already promoted in R2 will be overwritten, is this OK?
 ✓  Complete set of expected assets in place for v22.x
    Promote if you are certain this is the the correct course of action
$

@richardlau richardlau force-pushed the assets branch 2 times, most recently from bda6f57 to 1f52a06 Compare December 9, 2024 16:10
Add tool and tests for checking if assets on R2 look ready for
promotion. Relies on `rclone` being available -- there's a test for
the case where it is not.

The new tool is based on existing `check_assets.js` but:
- Written in ESM.
- Uses built-in Set objects instead of emulating sets with Arrays.
- Always assumes an asset file exists. `check_assets.js` has some
  fallback logic, but it's not straightforward and nowadays we can
  consider a missing asset file to be a process failure.
- Reflects that `.done` files are not used for R2 (basically they
  don't exist so no handling logic). Also note that for R2,
  promotion is a copy and not a move so after a partial promotion
  subsequent checks will result in overwrite warnings for files
  previously promoted.
- `SHASUMS256.txt` can end up in the staging directory. Ignore for
  the staging directory as `check_assets.js` does for dist. (The
  shasums are generated by later parts of the release process.)
Copy link
Member

@targos targos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very used to node:test but generally LGTM. Thanks!

console.log('... Checking R2 assets');
// No expected asset list available for this line
if (expectedAssets.size === 0) {
console.log(` \u001b[31m\u001b[1m✖\u001b[22m\u001b[39m No expected asset list is available for ${line}, does one need to be created?`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to ignore, but these could be simplified with util.styleText

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, but let's do that in a follow up. The same applies to check_assets.js.

@richardlau
Copy link
Member Author

I'm not very used to node:test but generally LGTM. Thanks!

Neither am I 🙂.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardlau richardlau merged commit 008cdd7 into main Dec 11, 2024
6 checks passed
@richardlau richardlau deleted the assets branch December 11, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update check_assets to also check in the R2 staging bucket
3 participants