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

report: fix network queries in getReport libuv with exclude-network #55602

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Tofandel
Copy link

@Tofandel Tofandel commented Oct 30, 2024

Fixes #55576 #46060

I also added in the endpoint's report info the keys ip4 or ip6 which contain the ip address of the endpoint (as well as information on which stack it was via the key)

Example of a tcp uv with network (default) (note that the reverse hostname resolving is up to the system dns resolver and some implementation may not resolve 127.0.0.1 to localhost for example on one of the ci server it resolves to test-ibm-rhel9-x64-1.nodejs.cloud)

[
  {
    type: 'tcp',
    is_active: true,
    is_referenced: true,
    address: '0x000055e70fcb85d8',
    localEndpoint: { host: 'localhost', ip4: '127.0.0.1', port: 48986 },
    remoteEndpoint: { host: 'localhost', ip4: '127.0.0.1', port: 38573 },
    sendBufferSize: 2626560,
    recvBufferSize: 131072,
    fd: 24,
    writeQueueSize: 0,
    readable: true,
    writable: true
  },
  {
    type: 'tcp',
    is_active: true,
    is_referenced: true,
    address: '0x000055e70fcd68c8',
    localEndpoint: { host: 'ip6-localhost', ip6: '::1', port: 52266 },
    remoteEndpoint: { host: 'ip6-localhost', ip6: '::1', port: 38573 },
    sendBufferSize: 2626560,
    recvBufferSize: 131072,
    fd: 25,
    writeQueueSize: 0,
    readable: true,
    writable: true
  }
]

Example of a tcp uv without network

[
  {
    type: 'tcp',
    is_active: true,
    is_referenced: true,
    address: '0x000055e70fcb85d8',
    localEndpoint: { host: '127.0.0.1', ip4: '127.0.0.1', port: 48986 },
    remoteEndpoint: { host: '127.0.0.1', ip4: '127.0.0.1', port: 38573 },
    sendBufferSize: 2626560,
    recvBufferSize: 131072,
    fd: 24,
    writeQueueSize: 0,
    readable: true,
    writable: true
  },
  {
    type: 'tcp',
    is_active: true,
    is_referenced: true,
    address: '0x000055e70fcd68c8',
    localEndpoint: { host: '::1', ip6: '::1', port: 52266 },
    remoteEndpoint: { host: '::1', ip6: '::1', port: 38573 },
    sendBufferSize: 2626560,
    recvBufferSize: 131072,
    fd: 25,
    writeQueueSize: 0,
    readable: true,
    writable: true
  }
]

The only difference between the two is that a reverse lookup is not performed on the host and will always contain the ip address without network (this is already the fallback if the reverse lookup fails, so that the change is almost invisible)

It would be nice if eventually getReport could be made to accept options instead of the very weird api with assignements and be made async instead and uv_getnameinfo made in async as well, but that's way too big a task for me to take on (I already barely stitched that PR together with my C++ knowledge which is non existant, I only know C)

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Oct 30, 2024
@RedYetiDev RedYetiDev added the report Issues and PRs related to process.report. label Oct 30, 2024
@RedYetiDev
Copy link
Member

Hi! Could you amend your commit to have a valid subsystem? In this case, src.

@Tofandel Tofandel changed the title fix: network queries in getReport libuv with --report-exclude-network src: network queries in getReport libuv with --report-exclude-network Oct 30, 2024
Comment on lines 42 to 97
it('should not do DNS queries in libuv if exclude network', async () => {
await fetch('http://127.0.0.1');

process.report.excludeNetwork = false;
let report = process.report.getReport();
let tcp = report.libuv.find((uv) => uv.type === 'tcp');
assert.notEqual(tcp, null);
assert.strictEqual(tcp.localEndpoint.host, 'localhost');
assert.strictEqual(tcp.remoteEndpoint.host, 'localhost');

process.report.excludeNetwork = true;
report = process.report.getReport();
tcp = report.libuv.find((uv) => uv.type === 'tcp');
assert.notEqual(tcp, null);
assert.strictEqual(tcp.localEndpoint.host, '127.0.0.1');
assert.strictEqual(tcp.remoteEndpoint.host, '127.0.0.1');
});
Copy link
Member

Choose a reason for hiding this comment

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

Does this have to go in test/internet?

Copy link
Author

Choose a reason for hiding this comment

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

Good question, it's still a test for getReport and the request is self contained to localhost, so does it make sense in internet?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know where it belongs, we'll see if someone else mentions it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this feature access the "internet". It just accesses local network information.

@Tofandel
Copy link
Author

This should be backported to node 20 and node 22 as well

@Tofandel Tofandel changed the title src: network queries in getReport libuv with --report-exclude-network report: fix network queries in getReport libuv with exclude-network Oct 30, 2024
@RedYetiDev
Copy link
Member

This should be backported to node 20 and node 22 as well

As long as it's not a semver-major change, which it's not at this point in time, it'll be planned to be backported.

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.41%. Comparing base (f67e45e) to head (0ab08f0).
Report is 59 commits behind head on main.

Files with missing lines Patch % Lines
src/node_report_utils.cc 89.28% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55602      +/-   ##
==========================================
- Coverage   88.44%   88.41%   -0.03%     
==========================================
  Files         654      654              
  Lines      187751   187761      +10     
  Branches    36146    36122      -24     
==========================================
- Hits       166050   166015      -35     
- Misses      14942    14994      +52     
+ Partials     6759     6752       -7     
Files with missing lines Coverage Δ
src/node_report.cc 93.16% <100.00%> (+0.01%) ⬆️
src/node_report.h 100.00% <ø> (ø)
src/node_report_utils.cc 80.10% <89.28%> (+5.54%) ⬆️

... and 60 files with indirect coverage changes

@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 31, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 31, 2024
@nodejs-github-bot
Copy link
Collaborator

@richardlau richardlau added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 31, 2024
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Oct 31, 2024
Copy link
Contributor

Failed to start CI
   ⚠  No approving reviews found
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/11619348784

@richardlau richardlau added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Nov 1, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 1, 2024
@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 6, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 6, 2024
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. report Issues and PRs related to process.report.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetReport takes very long times after http requests
6 participants