File tree 2 files changed +15
-0
lines changed
main/java/org/hypertrace/agent/otel/extensions
test/java/org/hypertrace/agent/otel/extensions
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ public String readContainerId() {
51
51
try (BufferedReader br = new BufferedReader (new FileReader (cgroupsPath ))) {
52
52
String line ;
53
53
while ((line = br .readLine ()) != null ) {
54
+ if (line .endsWith (".scope" )) {
55
+ line = line .substring (0 , line .length () - ".scope" .length ());
56
+ }
54
57
if (line .length () > CONTAINER_ID_LENGTH ) {
55
58
String id = line .substring (line .length () - CONTAINER_ID_LENGTH );
56
59
if (!id .contains ("/" )) {
Original file line number Diff line number Diff line change @@ -42,4 +42,16 @@ void readContainerId(@TempDir File tempFolder) throws IOException {
42
42
CgroupsReader cgroupsReader = new CgroupsReader (file .getPath ());
43
43
Assertions .assertEquals (expected , cgroupsReader .readContainerId ());
44
44
}
45
+
46
+ @ Test
47
+ void readScopedContainerId (@ TempDir File tempFolder ) throws IOException {
48
+ File file = new File (tempFolder , "cgroup" );
49
+ String expected = "736665661f3cf3ec691b2feeb2a1ec78918c0ef65381160bbb04f4c298169679" ;
50
+ String content =
51
+ "1:name=systemd:/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podab2df320_6a91_4bc7_bd18_0d4328f04a8f.slice/crio-736665661f3cf3ec691b2feeb2a1ec78918c0ef65381160bbb04f4c298169679.scope" ;
52
+ Files .write (content .getBytes (Charsets .UTF_8 ), file );
53
+
54
+ CgroupsReader cgroupsReader = new CgroupsReader (file .getPath ());
55
+ Assertions .assertEquals (expected , cgroupsReader .readContainerId ());
56
+ }
45
57
}
You can’t perform that action at this time.
0 commit comments