fix container ID parsing for cgroup v1 in EKS-Fargate#11110
fix container ID parsing for cgroup v1 in EKS-Fargate#11110
Conversation
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
|
Assigning to the apm-serverless team. I will follow up with the CODEOWNER update. |
| return 0; | ||
| } | ||
|
|
||
| public static class CGroupInfo { |
There was a problem hiding this comment.
This class looks like it is probably used across threads, but isn't thread safe.
Although, I guess that is problem that existed prior to this change.
| } | ||
|
|
||
| static ContainerInfo fromProcFile(Path path) throws IOException, ParseException { | ||
| final String content = new String(Files.readAllBytes(path)); |
There was a problem hiding this comment.
Are we assume a file encoding here? I guess this is just for Linux, but still it would be good to specify encoding.
And yes, I realize that's also a pre-existing problem.
| } | ||
|
|
||
| public static ContainerInfo parse(final String cgroupsContent) throws ParseException { | ||
| final ContainerInfo containerInfo = new ContainerInfo(); |
There was a problem hiding this comment.
Again, pre-existing.
I would prefer to see ContainerInfo be an immutable object.
Maybe, ContainerInfo could have a builder that helps with the construction process, and then produces an immutable ContainerInfo in the end.
| public static ContainerInfo parse(final String cgroupsContent) throws ParseException { | ||
| final ContainerInfo containerInfo = new ContainerInfo(); | ||
|
|
||
| final String[] lines = cgroupsContent.split("\n"); |
There was a problem hiding this comment.
Again pre-existing...
String split takes a regex. It would be better just to split on char.
I have a changeset that adds a lighter weight split to StringUtils.
| @Nullable String currentPodId, | ||
| String candidateContainerId, | ||
| @Nullable String candidatePodId) { | ||
| if (currentContainerId == null) { |
There was a problem hiding this comment.
I don't understand why we're passing all these fields if we aren't using them.
Do we envision this logic changing in the future?
There was a problem hiding this comment.
well, they are all used, but I can check if we can reduce the number of parameters
| return true; | ||
| } | ||
|
|
||
| if (currentContainerId.matches(CONTAINER_REGEX) && candidateContainerId.matches(TASK_REGEX)) { |
There was a problem hiding this comment.
General not a fan of regex-es because they are costly, but I'm assuming this code is run rarely.
dougqh
left a comment
There was a problem hiding this comment.
There are lot of pre-existing issues with ContainerInfo that I would like to see fixed at some point; however, those are outside the scope of this change.
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 61 metrics, 10 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.054 s) : 0, 1054351
Total [baseline] (10.984 s) : 0, 10984358
Agent [candidate] (1.058 s) : 0, 1057698
Total [candidate] (11.03 s) : 0, 11029619
section appsec
Agent [baseline] (1.248 s) : 0, 1247515
Total [baseline] (11.059 s) : 0, 11059270
Agent [candidate] (1.253 s) : 0, 1252636
Total [candidate] (11.196 s) : 0, 11196085
section iast
Agent [baseline] (1.224 s) : 0, 1223712
Total [baseline] (11.184 s) : 0, 11183796
Agent [candidate] (1.221 s) : 0, 1220808
Total [candidate] (11.244 s) : 0, 11243758
section profiling
Agent [baseline] (1.184 s) : 0, 1184412
Total [baseline] (11.074 s) : 0, 11073826
Agent [candidate] (1.185 s) : 0, 1184928
Total [candidate] (11.101 s) : 0, 11100609
gantt
title petclinic - break down per module: candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.223 ms) : 0, 1223
crashtracking [candidate] (1.221 ms) : 0, 1221
BytebuddyAgent [baseline] (631.137 ms) : 0, 631137
BytebuddyAgent [candidate] (631.304 ms) : 0, 631304
AgentMeter [baseline] (29.401 ms) : 0, 29401
AgentMeter [candidate] (29.35 ms) : 0, 29350
GlobalTracer [baseline] (249.643 ms) : 0, 249643
GlobalTracer [candidate] (248.755 ms) : 0, 248755
AppSec [baseline] (32.261 ms) : 0, 32261
AppSec [candidate] (32.323 ms) : 0, 32323
Debugger [baseline] (60.008 ms) : 0, 60008
Debugger [candidate] (60.07 ms) : 0, 60070
Remote Config [baseline] (594.419 µs) : 0, 594
Remote Config [candidate] (604.797 µs) : 0, 605
Telemetry [baseline] (8.07 ms) : 0, 8070
Telemetry [candidate] (8.063 ms) : 0, 8063
Flare Poller [baseline] (5.952 ms) : 0, 5952
Flare Poller [candidate] (9.819 ms) : 0, 9819
section appsec
crashtracking [baseline] (1.219 ms) : 0, 1219
crashtracking [candidate] (1.224 ms) : 0, 1224
BytebuddyAgent [baseline] (661.289 ms) : 0, 661289
BytebuddyAgent [candidate] (666.683 ms) : 0, 666683
AgentMeter [baseline] (12.117 ms) : 0, 12117
AgentMeter [candidate] (12.126 ms) : 0, 12126
GlobalTracer [baseline] (248.821 ms) : 0, 248821
GlobalTracer [candidate] (248.765 ms) : 0, 248765
IAST [baseline] (24.458 ms) : 0, 24458
IAST [candidate] (24.498 ms) : 0, 24498
AppSec [baseline] (184.926 ms) : 0, 184926
AppSec [candidate] (184.552 ms) : 0, 184552
Debugger [baseline] (65.775 ms) : 0, 65775
Debugger [candidate] (65.845 ms) : 0, 65845
Remote Config [baseline] (608.141 µs) : 0, 608
Remote Config [candidate] (620.991 µs) : 0, 621
Telemetry [baseline] (8.374 ms) : 0, 8374
Telemetry [candidate] (8.336 ms) : 0, 8336
Flare Poller [baseline] (3.513 ms) : 0, 3513
Flare Poller [candidate] (3.499 ms) : 0, 3499
section iast
crashtracking [baseline] (1.213 ms) : 0, 1213
crashtracking [candidate] (1.208 ms) : 0, 1208
BytebuddyAgent [baseline] (801.502 ms) : 0, 801502
BytebuddyAgent [candidate] (798.612 ms) : 0, 798612
AgentMeter [baseline] (11.397 ms) : 0, 11397
AgentMeter [candidate] (11.326 ms) : 0, 11326
GlobalTracer [baseline] (239.277 ms) : 0, 239277
GlobalTracer [candidate] (238.714 ms) : 0, 238714
IAST [baseline] (25.789 ms) : 0, 25789
IAST [candidate] (25.725 ms) : 0, 25725
AppSec [baseline] (32.605 ms) : 0, 32605
AppSec [candidate] (33.428 ms) : 0, 33428
Debugger [baseline] (58.466 ms) : 0, 58466
Debugger [candidate] (60.541 ms) : 0, 60541
Remote Config [baseline] (1.115 ms) : 0, 1115
Remote Config [candidate] (1.121 ms) : 0, 1121
Telemetry [baseline] (12.744 ms) : 0, 12744
Telemetry [candidate] (10.557 ms) : 0, 10557
Flare Poller [baseline] (3.407 ms) : 0, 3407
Flare Poller [candidate] (3.43 ms) : 0, 3430
section profiling
crashtracking [baseline] (1.174 ms) : 0, 1174
crashtracking [candidate] (1.186 ms) : 0, 1186
BytebuddyAgent [baseline] (691.05 ms) : 0, 691050
BytebuddyAgent [candidate] (691.93 ms) : 0, 691930
AgentMeter [baseline] (9.011 ms) : 0, 9011
AgentMeter [candidate] (9.106 ms) : 0, 9106
GlobalTracer [baseline] (206.933 ms) : 0, 206933
GlobalTracer [candidate] (207.283 ms) : 0, 207283
AppSec [baseline] (32.744 ms) : 0, 32744
AppSec [candidate] (32.774 ms) : 0, 32774
Debugger [baseline] (65.785 ms) : 0, 65785
Debugger [candidate] (65.512 ms) : 0, 65512
Remote Config [baseline] (584.574 µs) : 0, 585
Remote Config [candidate] (575.752 µs) : 0, 576
Telemetry [baseline] (7.845 ms) : 0, 7845
Telemetry [candidate] (7.837 ms) : 0, 7837
Flare Poller [baseline] (3.518 ms) : 0, 3518
Flare Poller [candidate] (3.576 ms) : 0, 3576
ProfilingAgent [baseline] (94.568 ms) : 0, 94568
ProfilingAgent [candidate] (93.852 ms) : 0, 93852
Profiling [baseline] (95.141 ms) : 0, 95141
Profiling [candidate] (94.423 ms) : 0, 94423
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.057 s) : 0, 1056884
Total [baseline] (8.826 s) : 0, 8825699
Agent [candidate] (1.058 s) : 0, 1057512
Total [candidate] (8.829 s) : 0, 8829421
section iast
Agent [baseline] (1.224 s) : 0, 1224337
Total [baseline] (9.574 s) : 0, 9574143
Agent [candidate] (1.227 s) : 0, 1227023
Total [candidate] (9.558 s) : 0, 9558128
gantt
title insecure-bank - break down per module: candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.24 ms) : 0, 1240
crashtracking [candidate] (1.233 ms) : 0, 1233
BytebuddyAgent [baseline] (631.992 ms) : 0, 631992
BytebuddyAgent [candidate] (632.15 ms) : 0, 632150
AgentMeter [baseline] (29.354 ms) : 0, 29354
AgentMeter [candidate] (29.421 ms) : 0, 29421
GlobalTracer [baseline] (248.914 ms) : 0, 248914
GlobalTracer [candidate] (248.855 ms) : 0, 248855
AppSec [baseline] (32.343 ms) : 0, 32343
AppSec [candidate] (32.304 ms) : 0, 32304
Debugger [baseline] (59.14 ms) : 0, 59140
Debugger [candidate] (59.017 ms) : 0, 59017
Remote Config [baseline] (590.103 µs) : 0, 590
Remote Config [candidate] (590.524 µs) : 0, 591
Telemetry [baseline] (8.057 ms) : 0, 8057
Telemetry [candidate] (7.987 ms) : 0, 7987
Flare Poller [baseline] (9.075 ms) : 0, 9075
Flare Poller [candidate] (9.644 ms) : 0, 9644
section iast
crashtracking [baseline] (1.246 ms) : 0, 1246
crashtracking [candidate] (1.215 ms) : 0, 1215
BytebuddyAgent [baseline] (801.188 ms) : 0, 801188
BytebuddyAgent [candidate] (802.441 ms) : 0, 802441
AgentMeter [baseline] (11.414 ms) : 0, 11414
AgentMeter [candidate] (11.464 ms) : 0, 11464
GlobalTracer [baseline] (239.193 ms) : 0, 239193
GlobalTracer [candidate] (241.125 ms) : 0, 241125
IAST [baseline] (25.891 ms) : 0, 25891
IAST [candidate] (25.984 ms) : 0, 25984
AppSec [baseline] (31.348 ms) : 0, 31348
AppSec [candidate] (30.526 ms) : 0, 30526
Debugger [baseline] (62.107 ms) : 0, 62107
Debugger [candidate] (61.67 ms) : 0, 61670
Remote Config [baseline] (547.236 µs) : 0, 547
Remote Config [candidate] (1.135 ms) : 0, 1135
Telemetry [baseline] (11.625 ms) : 0, 11625
Telemetry [candidate] (11.327 ms) : 0, 11327
Flare Poller [baseline] (3.469 ms) : 0, 3469
Flare Poller [candidate] (3.443 ms) : 0, 3443
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 4 performance regressions! Performance is the same for 16 metrics, 15 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section baseline
no_agent (1.244 ms) : 1233, 1256
. : milestone, 1244,
iast (3.437 ms) : 3386, 3488
. : milestone, 3437,
iast_FULL (5.81 ms) : 5753, 5867
. : milestone, 5810,
iast_GLOBAL (3.722 ms) : 3660, 3785
. : milestone, 3722,
profiling (2.203 ms) : 2181, 2224
. : milestone, 2203,
tracing (1.9 ms) : 1883, 1918
. : milestone, 1900,
section candidate
no_agent (1.256 ms) : 1243, 1268
. : milestone, 1256,
iast (3.234 ms) : 3196, 3272
. : milestone, 3234,
iast_FULL (5.969 ms) : 5910, 6029
. : milestone, 5969,
iast_GLOBAL (3.622 ms) : 3567, 3676
. : milestone, 3622,
profiling (2.449 ms) : 2421, 2477
. : milestone, 2449,
tracing (1.853 ms) : 1837, 1868
. : milestone, 1853,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section baseline
no_agent (19.322 ms) : 19122, 19523
. : milestone, 19322,
appsec (18.633 ms) : 18444, 18822
. : milestone, 18633,
code_origins (17.761 ms) : 17588, 17934
. : milestone, 17761,
iast (17.915 ms) : 17739, 18090
. : milestone, 17915,
profiling (18.38 ms) : 18201, 18560
. : milestone, 18380,
tracing (17.964 ms) : 17788, 18141
. : milestone, 17964,
section candidate
no_agent (18.155 ms) : 17973, 18336
. : milestone, 18155,
appsec (18.612 ms) : 18424, 18800
. : milestone, 18612,
code_origins (17.981 ms) : 17804, 18159
. : milestone, 17981,
iast (18.951 ms) : 18757, 19144
. : milestone, 18951,
profiling (18.62 ms) : 18435, 18804
. : milestone, 18620,
tracing (18.073 ms) : 17894, 18252
. : milestone, 18073,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 2 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section baseline
no_agent (1.499 ms) : 1487, 1511
. : milestone, 1499,
appsec (3.855 ms) : 3630, 4079
. : milestone, 3855,
iast (2.29 ms) : 2221, 2360
. : milestone, 2290,
iast_GLOBAL (2.326 ms) : 2256, 2396
. : milestone, 2326,
profiling (2.108 ms) : 2053, 2163
. : milestone, 2108,
tracing (2.092 ms) : 2038, 2145
. : milestone, 2092,
section candidate
no_agent (1.498 ms) : 1487, 1510
. : milestone, 1498,
appsec (3.858 ms) : 3635, 4081
. : milestone, 3858,
iast (2.299 ms) : 2229, 2368
. : milestone, 2299,
iast_GLOBAL (2.328 ms) : 2258, 2397
. : milestone, 2328,
profiling (2.535 ms) : 2369, 2702
. : milestone, 2535,
tracing (2.094 ms) : 2040, 2148
. : milestone, 2094,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~4ae7a6ae77, baseline=1.62.0-SNAPSHOT~da8bdd22c1
dateFormat X
axisFormat %s
section baseline
no_agent (15.276 s) : 15276000, 15276000
. : milestone, 15276000,
appsec (14.94 s) : 14940000, 14940000
. : milestone, 14940000,
iast (18.367 s) : 18367000, 18367000
. : milestone, 18367000,
iast_GLOBAL (18.094 s) : 18094000, 18094000
. : milestone, 18094000,
profiling (14.832 s) : 14832000, 14832000
. : milestone, 14832000,
tracing (14.938 s) : 14938000, 14938000
. : milestone, 14938000,
section candidate
no_agent (14.964 s) : 14964000, 14964000
. : milestone, 14964000,
appsec (14.667 s) : 14667000, 14667000
. : milestone, 14667000,
iast (18.83 s) : 18830000, 18830000
. : milestone, 18830000,
iast_GLOBAL (17.997 s) : 17997000, 17997000
. : milestone, 17997000,
profiling (14.857 s) : 14857000, 14857000
. : milestone, 14857000,
tracing (14.948 s) : 14948000, 14948000
. : milestone, 14948000,
|
What Does This Do
Prompted by an issue reported in APMS-19190
apparently, this customer uses EKS-Fargate with cgroup v1, and there is an extra line at the end of the cgroup following v2 format ? And that doesn't contain the container ID, and fools our parser ?
This comment highlights the issue pretty well
Motivation
Additional Notes
added a test with the output from the ticket
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.