-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NETPATH-100] TCP Traceroute Implementation POC #25714
Conversation
Go Package Import DifferencesBaseline: d407c3d
|
Regression DetectorRegression Detector ResultsRun ID: 52a59538-b2f9-4cb7-bac3-5327206624d0 Performance changes are noted in the perf column of each table:
No significant changes in experiment optimization goalsConfidence level: 90.00% There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.
|
perf | experiment | goal | Δ mean % | Δ mean % CI |
---|---|---|---|---|
➖ | tcp_syslog_to_blackhole | ingress throughput | +2.93 | [-18.54, +24.39] |
➖ | uds_dogstatsd_to_api_cpu | % cpu utilization | +1.17 | [-1.82, +4.17] |
➖ | basic_py_check | % cpu utilization | +0.10 | [-2.85, +3.05] |
➖ | trace_agent_msgpack | ingress throughput | +0.00 | [-0.00, +0.00] |
➖ | trace_agent_json | ingress throughput | -0.00 | [-0.01, +0.01] |
➖ | uds_dogstatsd_to_api | ingress throughput | -0.01 | [-0.21, +0.19] |
➖ | tcp_dd_logs_filter_exclude | ingress throughput | -0.03 | [-0.07, +0.02] |
➖ | otel_to_otel_logs | ingress throughput | -0.10 | [-0.48, +0.28] |
➖ | idle | memory utilization | -0.42 | [-0.47, -0.38] |
➖ | file_tree | memory utilization | -1.84 | [-1.98, -1.71] |
➖ | pycheck_1000_100byte_tags | % cpu utilization | -2.08 | [-6.81, +2.66] |
Explanation
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
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.
adding some light comments, but structure looks good!
One thing we may want to consider extracting the icmp/tcp calls to something mockable to get better test coverage.
var pathResult payload.NetworkPath | ||
switch protocol { | ||
case TCP: | ||
log.Debugf("Running TCP traceroute for: %+v", cfg) |
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.
Per the profiling data, we should be careful about logging here. It consumes a lot of CPU at scale.
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.
Is that something that continues to consume high CPU even if log level is set to info i.e. when this becomes a noop? Or is this just a concern for when debug logging is active
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.
IIRC it consumes much more when enabled, but the CPU is non-zero even if logging is disabled.
Also, we periodically tell customers to enable debug logging during support cases.
return checksum(append(pseudoHeader, tcpHeader...)) | ||
} | ||
|
||
func listenAnyPacket(icmpConn *ipv4.RawConn, tcpConn *ipv4.RawConn, timeout time.Duration, localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16) (net.IP, uint16, layers.ICMPv4TypeCode, error) { |
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.
two nits:
- documentation on this is appreciated! It's hard to tell what's happening just from the type signature
- I recommend reordering this file in function call order so this method appears before the helpers used by it https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering
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.
Added a comment to the re-named listenPacket
to explain what's going on and re-ordered the functions accordingly
src := util.AddressFromNetIP(res.Source) | ||
dst := util.AddressFromNetIP(res.Target) | ||
|
||
traceroutePath.Source.Via = r.gatewayLookup.LookupWithIPs(src, dst, r.nsIno) |
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 feel like this is fine to start, but NPM should already be doing a gateway lookup per IP -- have you thought about ways to share the lookup ?
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.
Yes, when I modified the Gateway lookup to work with traceroute, I tried to see if there was a way to share it and tried for a while to make it work but had some difficulties. I discussed with @hmahmood at the time and we agreed for now it was best to keep them separate.
I agree though, it would definitely be better if we could create some sort of singleton to share the caches or something along those lines.
TimeoutMs: 0, // TODO: make it configurable, setting 0 to use default value for now | ||
MaxTTL: 0, // TODO: make it configurable, setting 0 to use default value for now | ||
TimeoutMs: 0, // TODO: make it configurable, setting 0 to use default value for now | ||
Protocol: traceroute.TCP, // TODO: would we ever want UDP here? |
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 we should use the protocol from the NPM conns, some changes are needed to pass protocol from npCollectorImpl.ScheduleConns()
to PathtestContext
and then to traceroute.Config
here.
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.
Created a separate PR to merge into this one that handles this: #26110
Test changes on VMUse this command from test-infra-definitions to manually test this PR changes on a VM: inv create-vm --pipeline-id=35592411 --os-family=ubuntu |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25714 +/- ##
===========================================
- Coverage 45.17% 43.89% -1.29%
===========================================
Files 2349 319 -2030
Lines 270700 26699 -244001
===========================================
- Hits 122296 11720 -110576
+ Misses 138747 14446 -124301
+ Partials 9657 533 -9124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
if err != nil { | ||
return nil, err | ||
} | ||
defer conn.Close() |
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.
Wouldn't this free up the local port?
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.
It does, we don't really care about binding to the port, I'm just using this to get a random ephemeral port number to use from the OS to send on. Since we have a raw connection we can set whatever source information we want.
if err != nil { | ||
return net.IP{}, 0, 0, fmt.Errorf("failed to read: %w", err) | ||
} | ||
header, packet, _, err := conn.ReadFrom(buf) |
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.
Have you looked at https://pkg.go.dev/github.com/google/gopacket#hdr-Fast_Decoding_With_DecodingLayerParser for parsing the packet?
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 did, I found it a bit after I originally implemented this. I'm going to have to do it in 2 steps for ICMP since we sometimes have to extend the inner TCP header when the ICMP response doesn't contain the whole thing. There's a future iteration of this where it might make more sense to just do the unmarshal manually
default: | ||
} | ||
now := time.Now() | ||
err := conn.SetReadDeadline(now.Add(time.Millisecond * 100)) |
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.
Is this set for every iteration of the loop?
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.
Ignore the comment about epoll; The Readfrom
+ timeout should be the same.
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.
It is, I don't think there's a clean way to set the read deadline only once using a time.Duration
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.
It seems like there's no impact to @DataDog/processes, approving
|
||
// Create TCP packet with the specified flags | ||
// and sequence number | ||
tcpPacket := make([]byte, 20) |
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.
Could you use something like this https://pkg.go.dev/github.com/google/[email protected]/layers#TCP for constructing a tcp packet?
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.
Approving as this is behind a config flag, and the structure looks generally fine. I'll do a second review for follow ups next week! Specifically I think we want to get better testcoverage on tcpv4.go
Agreed, planning to get testing of both the tcpv4 and utils up |
/merge |
🚂 MergeQueue This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. Use |
🚂 MergeQueue Pull request added to the queue. There are 14 builds ahead! (estimated merge in less than 7h) Use |
https://datadoghq.atlassian.net/browse/NETPATH-100
What does this PR do?
This adds a TCPv4 implementation of traceroute to the agent. This allows for onboarding targets to Network Path that do not respond to UDP traceroutes.
Motivation
Allow better path tracing for TCP servers and services and more accurately trace paths that live traffic from the host might take for TCP connections.
Additional Notes
Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
conf.d/network_path.d/config.yaml
to target a web server and set protocol to TCP:system-probe.yaml
datadog.yaml
:/var/log/datadog/system-probe.log
and are succeeding.If you have it set to send traces to the back end, validate that the