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

Skip embedded Node.js runtime deployment if sonar.nodejs.executable is set #4616

Conversation

ilia-kebets-sonarsource
Copy link
Contributor

Fixes #4400

@ilia-kebets-sonarsource ilia-kebets-sonarsource requested review from vdiez and removed request for vdiez March 25, 2024 11:26
@ilia-kebets-sonarsource ilia-kebets-sonarsource requested review from vdiez and removed request for vdiez March 25, 2024 11:55
@ilia-kebets-sonarsource ilia-kebets-sonarsource changed the title Skip embedded Node.js runtime deployment if 'sonar.nodejs.executable' is set Skip embedded Node.js runtime deployment if sonar.nodejs.executable is set Mar 25, 2024
Copy link
Contributor

@zglicz zglicz left a comment

Choose a reason for hiding this comment

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

Requesting changes for using the already defined key for 'sonar.nodejs.executable'.
As in the comments, please consider saving the configuration on the BridgeServer if that makes sense.

Copy link
Contributor

@saberduck saberduck left a comment

Choose a reason for hiding this comment

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

I think it would be better to handle the condition in BridgeServer and do not push dependencies into EmbeddedNode

@ilia-kebets-sonarsource ilia-kebets-sonarsource removed the request for review from saberduck March 26, 2024 07:11
Comment on lines +728 to +738
var existingDoesntMatterScript = "logging.js";
bridgeServer = createBridgeServer(existingDoesntMatterScript);
context.setSettings(new MapSettings().setProperty(NODE_EXECUTABLE_PROPERTY, "whatever"));
assertThatThrownBy(() -> bridgeServer.startServerLazily(context))
.isInstanceOf(NodeCommandException.class);

assertThat(logTester.logs(INFO))
.contains(
"'" + NODE_EXECUTABLE_PROPERTY + "' is set. Skipping embedded Node.js runtime deployment."
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this, my idea was to run bridgeServer.startLazily() twice. First to extract a node runtime that would be used by the second call to it.
This requires quite a lot of boilerplate code since the helper functions in BridgeServerImplTest.java have hardcoded an unsupported platform for the BridgeServer EmbeddedNode instance.
Since I don't have an embedded runtime, it would require me to set a node executable depending on the platform, which is also cumbersome.

Copy link
Contributor

@zglicz zglicz left a comment

Choose a reason for hiding this comment

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

Huh, surprising that the code review still requires me specifically to review even if there is someone else who accepted. I'm used to only need to have a single accept, without counting how many request changes were there before, sorry for the wait.

I include a question about the FORCE_HOST flag and a small suggestion about the new test.

bundle.deploy(temporaryDeployLocation);
if (configuration.get(NODE_EXECUTABLE_PROPERTY).isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to your changes, but I assume this code is unreachable (this deploy method) if the user set the FORCE_HOST flag?

var existingDoesntMatterScript = "logging.js";
bridgeServer = createBridgeServer(existingDoesntMatterScript);
context.setSettings(new MapSettings().setProperty(NODE_EXECUTABLE_PROPERTY, "whatever"));
assertThatThrownBy(() -> bridgeServer.startServerLazily(context))
Copy link
Contributor

Choose a reason for hiding this comment

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

really funky that this would throw an error. This seems like it is testing the current behavior (as in, implementation detail) and not the actual functionality we want, which should be: "We will not try to load the Embedded node and instead only try the provided path".

I would imagine that the underlying implementation could change so that the server starts without any exception and correctly runs the provided path, and then this test would fail and be a false positive, by this test failing.

I do like the latter log check, as it shows this functionality you are adding. Perhaps we wouldn't assert that it throws above, just inspect the NodeCommand(?) doesn't try to access the embedded node?

@ilia-kebets-sonarsource ilia-kebets-sonarsource merged commit f71d3e0 into master Mar 26, 2024
19 checks passed
@ilia-kebets-sonarsource ilia-kebets-sonarsource deleted the i4400-do-not-deploy-runtime-if-sonar.nodejs.executable-is-set branch March 26, 2024 15:31
@saberduck
Copy link
Contributor

Huh, surprising that the code review still requires me specifically to review even if there is someone else who accepted. I'm used to only need to have a single accept, without counting how many request changes were there before, sorry for the wait.

I think we could configure it, maybe add a point to the weekly meeting to discuss it

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.

Do not deploy embedded Node.js runtime if sonar.nodejs.executable is set
4 participants