Skip to content

Commit 75ab855

Browse files
committed
fix(entity_id): Handle Podman cgroupns=host cgroup path with .scope/container suffix
systemd + cgroup v2 (cgroupns=host) │ ...libpod-<ID>.scope/container When a container runs with systemd + crgroup v2 (cgroupns=host) the cgroup path has /container after .scope. 0::/machine.slice/libpod-HEXID.scope/container (podman never seems to set anything other than the default "container" -- could find no reference to `run.oci.systemd.subgroup` -- but match other strings as well.
1 parent 15860bb commit 75ab855

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

libdd-common/src/entity_id/unix/container_id.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) static LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
2222
pub(crate) static CONTAINER_REGEX: LazyLock<Regex> = LazyLock::new(|| {
2323
#[allow(clippy::unwrap_used)]
2424
Regex::new(&format!(
25-
r"({UUID_SOURCE}|{CONTAINER_SOURCE}|{TASK_SOURCE})(?:.scope)? *$"
25+
r"({UUID_SOURCE}|{CONTAINER_SOURCE}|{TASK_SOURCE})(?:\.scope(?:/[^/ \t]+)?)? *$"
2626
))
2727
.unwrap()
2828
});
@@ -77,6 +77,9 @@ mod tests {
7777
=> Some("34dc0b5e626f2c5c4c5170e34b10e765-1234567890"),
7878
"1:name=systemd:/docker/34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376.scope"
7979
=> Some("34dc0b5e626f2c5c4c5170e34b10e7654ce36f0fcd532739f4445baabea03376"),
80+
// Podman cgroup v2: libpod-HEXID.scope/container (cgroupns=host)
81+
"0::/machine.slice/libpod-93afc7bc3ce42ad052d2926ffacfba941803bfae080941d1e1375d9d46b6a281.scope/container"
82+
=> Some("93afc7bc3ce42ad052d2926ffacfba941803bfae080941d1e1375d9d46b6a281"),
8083
// k8s with additional characters before ID
8184
"1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2d3da189_6407_48e3_9ab6_78188d75e609.slice/docker-7b8952daecf4c0e44bbcefe1b5c5ebc7b4839d4eefeccefe694709d3809b6199.scope"
8285
=> Some("7b8952daecf4c0e44bbcefe1b5c5ebc7b4839d4eefeccefe694709d3809b6199"),

0 commit comments

Comments
 (0)