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

Allow node patch versions to be higher on runtime #1189

Merged

Conversation

hashworks
Copy link
Contributor

This adjusts the runtime node version check to only compare major and minor version requirements. Systems that don't use the bundled NodeJS might update their node due to security patches, which would currently break OpenSearch Dashboards unnecessarily.

% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%

@hashworks hashworks requested a review from a team as a code owner January 28, 2022 12:11
@hashworks hashworks force-pushed the feature/majorMinorRuntimeCheck branch from b40dbb3 to 03f47ec Compare February 4, 2022 03:49
@hashworks hashworks requested a review from tmarkley February 4, 2022 03:51
@tmarkley
Copy link
Contributor

tmarkley commented Feb 8, 2022

Linting failed. Run yarn lint and then yarn lint:es --fix.

tmarkley
tmarkley previously approved these changes Feb 8, 2022
Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This looks good to me.

@boktorbb boktorbb self-requested a review February 8, 2022 21:03
boktorbb
boktorbb previously approved these changes Feb 8, 2022
Copy link
Contributor

@boktorbb boktorbb left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

@tmarkley tmarkley added the v1.3.0 label Feb 8, 2022
@kavilla
Copy link
Member

kavilla commented Feb 9, 2022

Hello @hashworks, thanks for the changes! Also, seems to resolve a big headache from the community.

Verified it seems to work great!

I could be overthinking. But I think it might be worth to have some indication of the version of Node.js that OpenSearch Dashboards was built with in the error message. As a developer on this project, it is pretty easy to find which explicit version to use but it might not be for others. The reason why I suggest this is that there is an inherit risk enabling a version that was not used in development and that was verified in a release process, albeit it small since it is a patch version. I'd rather if we could guide people on the verified version but let them know that they are empowered to make the decision that they accept the risk of using any other patch version could save a potential deep dive.

That said, the before behavior was always used the bundled node however now the logic seems seems to increase in more support that would be helpful to begin add to the documentation site, or least in a markdown file.

@kavilla
Copy link
Member

kavilla commented Feb 15, 2022

@hashworks any comment on the above? Let me know if I can answer any questions.

Thank you.

@hashworks
Copy link
Contributor Author

Sorry for the delay, I've been a bit busy lately.

Well, (pkg && pkg.engines && pkg.engines.node) already provides the version it was packaged with (since this refers to the version in the package.json, which is a hard build requirement). I guess we could adjust the text:

OpenSearch Dashboards was build with v14.17.3 and does not support the current Node.js version v14.16.2. Please use Node.js ~v14.17.

@kavilla
Copy link
Member

kavilla commented Feb 18, 2022

OpenSearch Dashboards was build with v14.17.3 and does not support the current Node.js version v14.16.2. Please use Node.js ~v14.17.

I think it would be built but I have definitely been wrong before. But I really like the message its helpful but provides a lot of insight without having to dive no further.

I +1 that message, @tmarkley, @boktorbb-amzn, @kgcreative, @keithhc2 any thoughts?

@keithhc2
Copy link

Agree that it should be built. +1 from me on the message as well.

@hashworks hashworks dismissed stale reviews from boktorbb and tmarkley via e34f2db February 19, 2022 13:17
@hashworks hashworks force-pushed the feature/majorMinorRuntimeCheck branch from e34f2db to 3e94742 Compare February 21, 2022 19:32
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks.

I see the 1.3 label is added to this, I'm hesitant to classify this as a minor version change since it's a major change in behavior (albeit it does a less strict check).

@tmarkley
Copy link
Contributor

I see the 1.3 label is added to this, I'm hesitant to classify this as a minor version change since it's a major change in behavior (albeit it does a less strict check).

@kavilla that's reasonable, especially since 1.x is still on Node.js v10.

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements! I think there's an opportunity to add a few more tests, but otherwise this looks great.

src/setup_node_env/node_version_validator.test.js Outdated Show resolved Hide resolved
src/setup_node_env/node_version_validator.test.js Outdated Show resolved Hide resolved
@@ -37,15 +37,18 @@ var pkg = require('../../package.json');
var currentVersion = (process && process.version) || null;
var rawRequiredVersion = (pkg && pkg.engines && pkg.engines.node) || null;
var requiredVersion = rawRequiredVersion ? 'v' + rawRequiredVersion : rawRequiredVersion;
var isVersionValid = !!currentVersion && !!requiredVersion && currentVersion === requiredVersion;
var requiredVersionMajorMinor = requiredVersion.match(/^v(\d+\.\d+)/)[1];
var isVersionValid = requiredVersionMajorMinor === currentVersion.match(/^v(\d+\.\d+)/)[1];

// Validates current the NodeJS version compatibility when OpenSearch Dashboards starts.
if (!isVersionValid) {
var errorMessage =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add at least one test to confirm that this error message spits out what we expect? I don't see any current tests that validate these regex expressions.

Copy link
Contributor Author

@hashworks hashworks Apr 14, 2022

Choose a reason for hiding this comment

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

Added in 14166cd... but please verify that this is what you had in mind. I can't really test a fixed string because it changes with the used node version.

src/setup_node_env/node_version_validator.js Outdated Show resolved Hide resolved
@kavilla kavilla removed the v1.3.0 label Feb 23, 2022
@tmarkley tmarkley added the v2.0.0 label Mar 3, 2022
@kavilla kavilla added v2.1.0 and removed v2.0.0 labels Apr 7, 2022
@kavilla
Copy link
Member

kavilla commented Apr 7, 2022

I have moved this 2.1.0 because I think we should act on Tommy's responses but I think we can build this in a way that enables us to call this a feature. Sorry about the delay on this.

Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

Blocking to ensure 2.0.0-rc1 stability.

@hashworks hashworks force-pushed the feature/majorMinorRuntimeCheck branch 2 times, most recently from d2b7bd4 to fa69e60 Compare April 14, 2022 14:45
@hashworks
Copy link
Contributor Author

I have moved this 2.1.0 because I think we should act on Tommy's responses but I think we can build this in a way that enables us to call this a feature. Sorry about the delay on this.

My bad, I didn't have time to fix things up.

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

Signed-off-by: Justin Kromlinger <[email protected]>
Tests versions that are greater than and less than the current version.

Signed-off-by: Justin Kromlinger <[email protected]>
@hashworks hashworks force-pushed the feature/majorMinorRuntimeCheck branch from a28c8ed to 0218576 Compare April 28, 2022 15:08
@hashworks hashworks requested review from kavilla and tmarkley April 28, 2022 15:10
@hashworks hashworks changed the title Allow node patch versions to be different on runtime Allow node patch versions to be higher on runtime Apr 28, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1189 (0218576) into main (1ad1a8b) will increase coverage by 0.00%.
The diff coverage is 75.00%.

@@           Coverage Diff           @@
##             main    #1189   +/-   ##
=======================================
  Coverage   68.09%   68.09%           
=======================================
  Files        3072     3072           
  Lines       59032    59034    +2     
  Branches     8928     8928           
=======================================
+ Hits        40198    40200    +2     
  Misses      16647    16647           
  Partials     2187     2187           
Impacted Files Coverage Δ
src/setup_node_env/node_version_validator.js 72.72% <75.00%> (+6.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ad1a8b...0218576. Read the comment docs.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Thanks for adding these tests. Love how you are testing for the different major, minor and patch versions.

Copy link
Contributor

@tmarkley tmarkley left a comment

Choose a reason for hiding this comment

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

Thanks so much for the improvements! This looks great.

Copy link
Contributor

@boktorbb boktorbb left a comment

Choose a reason for hiding this comment

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

Great work! Thank you

@kavilla
Copy link
Member

kavilla commented Jun 1, 2022

Just wanted to follow up, as you stated before it help people who do not have the pre-bundled Node. Will just re-hash that behavior might seem inconsistent for end-users and developers who do not have the insight here. Perhaps we can add the needs-documentation label to create an issue for this behavior. Or do we think maybe we can pivot this to use: #1219, where we just check if this environment variable is set and just skip the verification logic in general, or keep this original logic intact and only execute this new logic if the environment variable is set.

@kavilla kavilla dismissed their stale review June 1, 2022 23:39

Good as is, potentially needs docs or env variable

@ashwin-pc
Copy link
Member

@kavilla Added the label and we can address the node_home env when we get to #1219. There we can add a check to skip this if the flag is set. since we dont have support for that flag yet, I dont think it makes sense in introducing that logic right now.

@tmarkley tmarkley merged commit 0a24652 into opensearch-project:main Jun 6, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 6, 2022
This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
(cherry picked from commit 0a24652)
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 8, 2022
…#1189)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 8, 2022
…#1189)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
tmarkley pushed a commit that referenced this pull request Jun 14, 2022
This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
(cherry picked from commit 0a24652)
kavilla pushed a commit to kavilla/OpenSearch-Dashboards-1 that referenced this pull request Jun 16, 2022
…#1189)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
cliu123 pushed a commit to cliu123/OpenSearch-Dashboards that referenced this pull request Jun 30, 2022
…#1189) (opensearch-project#1677)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
(cherry picked from commit 0a24652)
cliu123 pushed a commit to cliu123/OpenSearch-Dashboards that referenced this pull request Jun 30, 2022
…#1189) (opensearch-project#1677)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
(cherry picked from commit 0a24652)
pjfitzgibbons pushed a commit to pjfitzgibbons/OpenSearch-Dashboards that referenced this pull request Aug 10, 2022
…#1189)

This adjusts the runtime node version check to only compare major and
minor version requirements. Systems that don't use the bundled NodeJS
might update their node due to security patches, which would currently
break OpenSearch Dashboards unnecessarily.

```shell
% grep 14.18 ../../package.json
    "node": "14.18.2",
% nvm use 12
Now using node v12.22.8 (npm v6.14.15)
% node node_version_validator.js
OpenSearch Dashboards does not support the current Node.js version v12.22.8. Please use Node.js ~v14.18.
% nvm use 14
Now using node v14.18.3 (npm v6.14.15)
% node node_version_validator.js
%
```

* Mention Node.js version Dashboards was built with in runtime check error
* Use template literals in node version validator
* Add additional node validator tests, cleanup
* Don't allow node patch versions to be lower on runtime

Signed-off-by: Justin Kromlinger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants