-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[build] Check SHA sum of downloaded node package #7746
Conversation
@@ -6,6 +6,7 @@ module.exports = function (grunt) { | |||
'clean:build', | |||
'clean:target', | |||
'_build:downloadNodeBuilds:start', | |||
'_build:downloadNodeBuilds:finish', |
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.
The reason why we put downloadNodeBuilds:finish further down the build task is to allow other build tasks to occur while the binaries are downloading. I'm not opposed to blocking entirely on the downloadNodeBuilds task if that's necessary, but if it is, we should roll it all into a single task.
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 think that download usually takes less than 1 minute and the rest of the build process takes around 10 minutes. so it doesn't feel right to wait for 10 minutes just to find out that my node binaries are corrupt. however we could put it a bit further down the line. in my opinion joining the tasks into one would be the cleanest solution (as download is usually fast).
let me know
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.
Joining them works for me.
Haven't figured out exactly why yet, but sha checks are failing for me when I run a build. |
map(platforms, start).nodeify(this.async()); | ||
getShaSums(); |
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.
Shouldn't we download the checksums first? This looks like a race condition waiting to happen. And I think ideally we'd pass them in as an argument rather than using a mutable variable in the closure.
Ah. So I think because the SHA check happens in the download function, it gets skipped the second time you run a build, even if it failed the first time (line 20 skips everything if the directory already exists). We should probably re-check the SHA every time a build is run, regardless of whether the binary was just downloaded, or pre-existing. |
.on('end', () => { | ||
return cb(null, content); | ||
}); | ||
}); |
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.
You should be able to get rid of a lot of the complexity by using wreck.get
, like this:
const resp = await fromNode(cb => {
wreck.get(shaSumsUri, function (err, resp, payload) {
console.log('in get');
if (err) {
return cb(err);
}
if (resp.statusCode !== 200) {
return cb(new Error(`${shaSumsUri} failed with a ${resp.statusCode} response`));
}
cb(null, payload);
});
});
resp.toString('utf8').split('\n').forEach(line => {
let cells = line.split(' ');
shaSums[cells[1]] = cells[0];
});
jenkins, test it |
@@ -93,6 +93,7 @@ | |||
"boom": "2.8.0", | |||
"brace": "0.5.1", | |||
"bunyan": "1.7.1", | |||
"check-hash": "1.0.0", |
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.
1.0.1 is the latest.
@Bargs my assumption was that if download was successful we don't need to check shasums the next time. shasum is only checked after download, if its correct archive is extracted and next time we don't need to check shasums. if download failed archive wont be extracted ... so it should be downloaded and checked again. why do you think it would be necesary to recheck shasums every time ? |
i was under wrong assumption that folder will only exist in case download was successful (content extracted). i added code which will remove folder in case download failed. this way it should be redownloaded next time, but wont be redownloading in case download was successful (so we don't unnecessarily slow down the build + we can build while offline once packages have been downloaded) |
Honestly, I think it's safer to check the shasum each time regardless of download. The build process is how we create production quality release candidates, so the process should be resilient to outside factors. It shouldn't be possible for me to manually add a file to the node binary directory and have the build process bundle it up. In other words, assumptions like "well, there's a file where it is suppose to be so I assume we're good" are not cautious enough when it comes to creating official releases. |
ok, so i try to do this now:
does this sound ok ? |
Works for me |
@ppisljar Just a few more things:
|
Assuming that build goes green, LGTM Can you update the PR description with more information about this change before merging? Specifically, describe the new |
jenkins, test this |
Backports PR #7746 **Commit 1:** fix #7136 - check SHA of downloaded node binaries * Original sha: 955972b * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-07-11T19:17:08Z **Commit 2:** only skipping download if --skip-download cli argument is present * Original sha: 325e172 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-07T10:54:23Z **Commit 3:** updating log messages based on epixas comments * Original sha: 20b5c4d * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:24:55Z **Commit 4:** updating based on courts review * Original sha: 78c124c * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-10-29T14:44:43Z
Backports PR #7746 **Commit 1:** fix #7136 - check SHA of downloaded node binaries * Original sha: 955972b * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-07-11T19:17:08Z **Commit 2:** only skipping download if --skip-download cli argument is present * Original sha: 325e172 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-07T10:54:23Z **Commit 3:** updating log messages based on epixas comments * Original sha: 20b5c4d * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:24:55Z **Commit 4:** updating based on courts review * Original sha: 78c124c * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-10-29T14:44:43Z
Backports PR #7746 **Commit 1:** fix #7136 - check SHA of downloaded node binaries * Original sha: 955972b * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-07-11T19:17:08Z **Commit 2:** only skipping download if --skip-download cli argument is present * Original sha: 325e172 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-07T10:54:23Z **Commit 3:** updating log messages based on epixas comments * Original sha: 20b5c4d * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:24:55Z **Commit 4:** updating based on courts review * Original sha: 78c124c * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-10-29T14:44:43Z
Backports PR #7746 **Commit 1:** fix #7136 - check SHA of downloaded node binaries * Original sha: 955972b * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-07-11T19:17:08Z **Commit 2:** only skipping download if --skip-download cli argument is present * Original sha: 325e172 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-07T10:54:23Z **Commit 3:** updating log messages based on epixas comments * Original sha: 20b5c4d * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:24:55Z **Commit 4:** updating based on courts review * Original sha: 78c124c * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-10-29T14:44:43Z
* fix elastic#7136 - check SHA of downloaded node binaries * skips download if --skip-node-download cli argument is present
Backports PR elastic#7746 **Commit 1:** fix elastic#7136 - check SHA of downloaded node binaries * Original sha: 955972b * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-07-11T19:17:08Z **Commit 2:** only skipping download if --skip-download cli argument is present * Original sha: 325e172 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-07T10:54:23Z **Commit 3:** updating log messages based on epixas comments * Original sha: 20b5c4d * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:24:55Z **Commit 4:** updating based on courts review * Original sha: 78c124c * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-10-29T14:44:43Z Former-commit-id: 8e22a9e
checks SHA checksum for downloaded node packages and throws error if cheksum doesnt match (after up to 3 retries).
--skip-node-download
option can be passed to grunt task to skip download of node builds in case they were downloaded before. SHA verification still happens and throws an error in case it fails.Fixes #7136
Fixes #7482