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

cluster: overriding inspector port #14140

Merged
merged 3 commits into from
Jul 14, 2017

Conversation

mutantcornholio
Copy link
Contributor

@mutantcornholio mutantcornholio commented Jul 8, 2017

As suggested in #13761 (comment), I've added new option inspectPort to cluster.settings.

This allows to override inspect port incrementing behavior.

Two main configurations that need this:

  • One master and one worker. Master runs without inspector. Worker runs with inspector on specified port.
  • Cluster with many workers, all process with --inspect=0. If we want whole cluster run with inspector and don't want to catch port collisions, we run master with --inspect=0 and use setupMaster(inspectPort: 0) to override port increment.

Fixes: #8495
Fixes: #12941
Ref: #9659
Ref: #13761

[refack] rearranged references so metadata generated better detects them

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

cluster

@nodejs-github-bot nodejs-github-bot added the cluster Issues and PRs related to the cluster subsystem. label Jul 8, 2017
@mutantcornholio
Copy link
Contributor Author

cc/ @refack @Trott @mcollina

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Beautifull

@refack
Copy link
Contributor

refack commented Jul 8, 2017

@mutantcornholio
Copy link
Contributor Author

Running JS linter...
./node tools/jslint.js -j 2 -f tap -o test-eslint.tap \
	benchmark doc lib test tools
gmake: *** [Makefile:876: jslint-ci] Error 1

Is something's wrong with CI?

@joaocgreis
Copy link
Member

I aborted the CI run becuase one of the windows workers was stuck, unrelated to this PR.

@mutantcornholio about the linter, there is indeed an error here, but the CI job does not show details:

C:\Users\Administrator\Desktop\node\test\inspector\test-inspector-port-cluster.js
  107:53  error  Strings must use singlequote  quotes

@refack
Copy link
Contributor

refack commented Jul 9, 2017

Is something's wrong with CI?

Yes and no. It's a known limitation that currently Jenkins can't parse the linter's output nodejs/build#720

@refack
Copy link
Contributor

refack commented Jul 9, 2017

@mutantcornholio if you go the the CI runner just after the job ended you can view the TAP output:

not ok 20 - /usr/home/iojs/build/workspace/node-test-linter/test/inspector/test-inspector-port-cluster.js
  ---
  message: Strings must use singlequote.
  severity: error
  data:
    line: 107
    column: 53
    ruleId: quotes
  ...

@Trott
Copy link
Member

Trott commented Jul 9, 2017

/cc @bnoordhuis @cjihrig

@mutantcornholio
Copy link
Contributor Author

Fixed codestyle, thanks.

@refack
Copy link
Contributor

refack commented Jul 9, 2017

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM as semver-minor. However, I would say do not backport to 6, and just land it in 8.


for (const worker of workers) {
if (clusterSettings) {
if (clusterSettings.inspectPort === 'addTwo') {
clusterSettings.inspectPort = () => { return debugPort += 2; };
Copy link
Member

Choose a reason for hiding this comment

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

can you please add a common.mustCall here?

@mcollina mcollina added dont-land-on-v4.x semver-minor PRs that contain new features and should be released in the next minor version. labels Jul 10, 2017
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

Can you please split all of the unrelated changes into separate commits or PRs.

debugPortOffset++;
let inspectPort;
if (cluster.settings.inspectPort) {
if (typeof cluster.settings.inspectPort === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: no curly braces for single line if statements.

@mutantcornholio
Copy link
Contributor Author

Can you please split all of the unrelated changes into separate commits or PRs.

You mean style changes in docs? Or is there anything else?

@cjihrig
Copy link
Contributor

cjihrig commented Jul 10, 2017

I meant the unrelated documentation changes. The change in offset from 10 to 5 is probably not needed either.

@mutantcornholio
Copy link
Contributor Author

The change in offset from 10 to 5 is probably not needed either.

It is needed because I've added some tests and reached 100 ports "limit" per test file.

Would it be sufficient if I break the changes into several commits, but it all will stay in one PR?

@cjihrig
Copy link
Contributor

cjihrig commented Jul 10, 2017

Different commits in the same PR is OK. In the future, I'd say separate PRs though.

const debugOptions = process.binding('config').debugOptions;

if (+expectedPort) {
assert.strictEqual(process.debugPort, +expectedPort);
Copy link
Contributor

Choose a reason for hiding this comment

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

semantic nit: I'd rather you test

if ('expectedPort' in process.env)
  assert.strictEqual(process.debugPort, Number(expectedPort));

And the next test.


port = debuggerPort + offset++ * 5;

spawnMaster({
Copy link
Contributor

@refack refack Jul 10, 2017

Choose a reason for hiding this comment

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

Could you add a test for the trivial case:

{
  execArgv: ['--inspect'],
  clusterSettings: {inspectPort: port + 2},
  workers: [{expectedPort: port + 2}]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to rewrite tests a little bit for this, but made it.

@mutantcornholio mutantcornholio force-pushed the cluster-inspect-override-1 branch 2 times, most recently from 6c2fe24 to 17a1611 Compare July 10, 2017 20:02
@mutantcornholio
Copy link
Contributor Author

@mcollina @refack @cjihrig done!

@refack refack force-pushed the cluster-inspect-override-1 branch from b20864c to b430053 Compare July 14, 2017 23:16
@refack refack merged commit b430053 into nodejs:master Jul 14, 2017
@refack
Copy link
Contributor

refack commented Jul 14, 2017

freeBSD fail is unrelated - #14241
plinux fail is known - #14206

Landed in b430053 592b0ed ca5b0c4

Long ride #9659 -> #13761 -> here

@refack
Copy link
Contributor

refack commented Jul 14, 2017

@mutantcornholio don't you want your real name in the commit logs? Too late for this one, but if when you do another PR here's the guide https://help.github.com/articles/setting-your-username-in-git/

@mutantcornholio
Copy link
Contributor Author

I kinda got used to Cornholio <0@mcornholio.ru>, but I'll think about it :)

@refack
Copy link
Contributor

refack commented Jul 15, 2017

I kinda got used to Cornholio 0@mcornholio.ru, but I'll think about it :)

For a long time I wanted to ask if you need T.P.?
image

addaleax added a commit to addaleax/node that referenced this pull request Jul 18, 2017
- Add missing `changes:` entry
- Use full sentences
- Use proper indentation

Ref: nodejs#14140
PR-URL: nodejs#14349
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@addaleax addaleax mentioned this pull request Jul 18, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
* Capitalization and punctuation.

* `setupMaster` contained info about `settings` which where incomplete.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit that referenced this pull request Jul 18, 2017
10 ports for each test-case is too much.
Not enough ports for new test cases, considering ~100 ports per file.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit that referenced this pull request Jul 18, 2017
Added an option to override inspector port for workers using
`settings.inspectPort` will override default port incrementing behavior.
Also, using this option allows to set 0 port for the whole cluster.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax added a commit that referenced this pull request Jul 18, 2017
- Add missing `changes:` entry
- Use full sentences
- Use proper indentation

Ref: #14140
PR-URL: #14349
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax added a commit that referenced this pull request Jul 18, 2017
Notable changes:

* **Async Hooks**
  * Multiple improvements to Promise support in `async_hooks` have been made.

* **Build**
  * The compiler version requirement to build Node with GCC has been raised to
    GCC 4.9.4.
    [[`820b011ed6`](820b011ed6)]
    [#13466](#13466)

* **Cluster**
  * Users now have more fine-grained control over the inspector port used by
    individual cluster workers. Previously, cluster workers would simply
    increment from the master's debug port.
    [[`dfc46e262a`](dfc46e262a)]
    [#14140](#14140)

* **DNS**
  * The server used for DNS queries can now use a custom port.
    [[`ebe7bb29aa`](ebe7bb29aa)]
    [#13723](#13723)
  * Support for `dns.resolveAny()` has been added.
    [[`6e30e2558e`](6e30e2558e)]
    [#13137](#13137)

* **npm**
  * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes
    with the `npx` binary, which is also shipped with Node.
    [[`dc3f6b9ac1`](dc3f6b9ac1)]
    [#14235](#14235)
  * `npm` Changelogs:
      - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4)
      - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0)
      - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0)
      - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0)

PR-URL: #13744
addaleax added a commit that referenced this pull request Jul 18, 2017
- Add missing `changes:` entry
- Use full sentences
- Use proper indentation

Ref: #14140
PR-URL: #14349
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Jul 19, 2017
Big thanks to @addaleax who prepared the vast majority of this release.

Notable changes:

* **Async Hooks**
  * Multiple improvements to Promise support in `async_hooks` have been made.

* **Build**
  * The compiler version requirement to build Node with GCC has been raised to
    GCC 4.9.4.
    [[`820b011ed6`](nodejs@820b011ed6)]
    [nodejs#13466](nodejs#13466)

* **Cluster**
  * Users now have more fine-grained control over the inspector port used by
    individual cluster workers. Previously, cluster workers would simply
    increment from the master's debug port.
    [[`dfc46e262a`](nodejs@dfc46e262a)]
    [nodejs#14140](nodejs#14140)

* **DNS**
  * The server used for DNS queries can now use a custom port.
    [[`ebe7bb29aa`](nodejs@ebe7bb29aa)]
    [nodejs#13723](nodejs#13723)
  * Support for `dns.resolveAny()` has been added.
    [[`6e30e2558e`](nodejs@6e30e2558e)]
    [nodejs#13137](nodejs#13137)

* **npm**
  * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes
    with the `npx` binary, which is also shipped with Node.
    [[`dc3f6b9ac1`](nodejs@dc3f6b9ac1)]
    [nodejs#14235](nodejs#14235)
  * `npm` Changelogs:
      - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4)
      - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0)
      - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0)
      - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0)

PR-URL: nodejs#13744
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
* Capitalization and punctuation.

* `setupMaster` contained info about `settings` which where incomplete.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
10 ports for each test-case is too much.
Not enough ports for new test cases, considering ~100 ports per file.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
Added an option to override inspector port for workers using
`settings.inspectPort` will override default port incrementing behavior.
Also, using this option allows to set 0 port for the whole cluster.

PR-URL: #14140
Fixes: #8495
Fixes: #12941
Refs: #9659
Refs: #13761
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
- Add missing `changes:` entry
- Use full sentences
- Use proper indentation

Ref: #14140
PR-URL: #14349
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fishrock123 added a commit that referenced this pull request Jul 19, 2017
Big thanks to @addaleax who prepared the vast majority of this release.

Notable changes:

* **Async Hooks**
  * Multiple improvements to Promise support in `async_hooks` have been made.

* **Build**
  * The compiler version requirement to build Node with GCC has been raised to
    GCC 4.9.4.
    [[`820b011ed6`](820b011ed6)]
    [#13466](#13466)

* **Cluster**
  * Users now have more fine-grained control over the inspector port used by
    individual cluster workers. Previously, cluster workers would simply
    increment from the master's debug port.
    [[`dfc46e262a`](dfc46e262a)]
    [#14140](#14140)

* **DNS**
  * The server used for DNS queries can now use a custom port.
    [[`ebe7bb29aa`](ebe7bb29aa)]
    [#13723](#13723)
  * Support for `dns.resolveAny()` has been added.
    [[`6e30e2558e`](6e30e2558e)]
    [#13137](#13137)

* **npm**
  * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes
    with the `npx` binary, which is also shipped with Node.
    [[`dc3f6b9ac1`](dc3f6b9ac1)]
    [#14235](#14235)
  * `npm` Changelogs:
      - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4)
      - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0)
      - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0)
      - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0)

PR-URL: #13744
Fishrock123 added a commit that referenced this pull request Jul 19, 2017
Big thanks to @addaleax who prepared the vast majority of this release.

Notable changes:

* **Async Hooks**
  * Multiple improvements to Promise support in `async_hooks` have been made.

* **Build**
  * The compiler version requirement to build Node with GCC has been raised to
    GCC 4.9.4.
    [[`820b011ed6`](820b011ed6)]
    [#13466](#13466)

* **Cluster**
  * Users now have more fine-grained control over the inspector port used by
    individual cluster workers. Previously, cluster workers would simply
    increment from the master's debug port.
    [[`dfc46e262a`](dfc46e262a)]
    [#14140](#14140)

* **DNS**
  * The server used for DNS queries can now use a custom port.
    [[`ebe7bb29aa`](ebe7bb29aa)]
    [#13723](#13723)
  * Support for `dns.resolveAny()` has been added.
    [[`6e30e2558e`](6e30e2558e)]
    [#13137](#13137)

* **npm**
  * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes
    with the `npx` binary, which is also shipped with Node.
    [[`dc3f6b9ac1`](dc3f6b9ac1)]
    [#14235](#14235)
  * `npm` Changelogs:
      - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4)
      - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0)
      - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0)
      - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0)

PR-URL: #13744
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Programatically setting the debug flag has no effects debugging and fork (Error: listen EADDRINUSE :::5858)
8 participants