@@ -11,6 +11,9 @@ use std::sync::LazyLock;
1111
1212const UUID_SOURCE : & str =
1313 r"[0-9a-f]{8}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{12}" ;
14+ /// PCF / Garden container UUID source: 8-4-4-4-4 hex (28 chars).
15+ /// Distinct from `UUID_SOURCE` (8-4-4-4-12) because the last group is 4 hex.
16+ const PCF_UUID_SOURCE : & str = r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}" ;
1417const CONTAINER_SOURCE : & str = r"[0-9a-f]{64}" ;
1518const TASK_SOURCE : & str = r"[0-9a-f]{32}-\d+" ;
1619
@@ -22,7 +25,7 @@ pub(crate) static LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
2225pub ( crate ) static CONTAINER_REGEX : LazyLock < Regex > = LazyLock :: new ( || {
2326 #[ allow( clippy:: unwrap_used) ]
2427 Regex :: new ( & format ! (
25- r"({UUID_SOURCE}|{CONTAINER_SOURCE}|{TASK_SOURCE})(?:\.scope(?:/[^/ \t]+)?)? *$"
28+ r"({UUID_SOURCE}|{PCF_UUID_SOURCE}|{ CONTAINER_SOURCE}|{TASK_SOURCE})(?:\.scope(?:/[^/ \t]+)?)? *$"
2629 ) )
2730 . unwrap ( )
2831} ) ;
@@ -92,6 +95,17 @@ mod tests {
9295 // invalid hex
9396 "13:name=systemd:/docker/3726184226f5d3147g25fdeab5b60097e378e8a720503a5e19ecfdf29f869860"
9497 => None ,
98+ // PCF Garden 8-4-4-4-4 UUID
99+ "1:name=systemd:/system.slice/garden.service/garden/6f265890-5165-7fab-6b52-18d1"
100+ => Some ( "6f265890-5165-7fab-6b52-18d1" ) ,
101+ "10:freezer:/garden/6f265890-5165-7fab-6b52-18d1"
102+ => Some ( "6f265890-5165-7fab-6b52-18d1" ) ,
103+ // Regression guard: 8-4-4-4-12 standard UUID must NOT be truncated to 28 chars
104+ "1:name=systemd:/uuid/5a081c13-b8cf-4801-b427-f4601742204d"
105+ => Some ( "5a081c13-b8cf-4801-b427-f4601742204d" ) ,
106+ // First group only 7 chars -> no match
107+ "1:name=systemd:/garden/6f26589-5165-7fab-6b52-18d1"
108+ => None ,
95109 } ;
96110 for ( line, & expected_result) in test_lines. iter ( ) {
97111 assert_eq ! (
@@ -118,6 +132,7 @@ mod tests {
118132 "cgroup.fargate" => Some ( "432624d2150b349fe35ba397284dea788c2bf66b885d14dfc1569b01890ca7da" ) ,
119133 // parse a Fargate 1.4+ container ID
120134 "cgroup.fargate.1.4" => Some ( "8cd79a803caf4d2aa945152e934a5c00-1053176469" ) ,
135+ "cgroup.pcf" => Some ( "6f265890-5165-7fab-6b52-18d1" ) ,
121136
122137 // Whitespace around the matching ID is permitted so long as it is matched within a valid cgroup line.
123138 // parse a container ID with leading and trailing whitespace
0 commit comments