Skip to content

Commit

Permalink
Fix LXC/LXD and machined detection for cgroups v2
Browse files Browse the repository at this point in the history
The second field is always blank in cgroups v2 unlike v1, adjust parsing to
support both cases for LXC/LXD and machined. This is the same fix as previously
made for Docker in liske#234.

Example: 0::/lxc.payload.focal/system.slice/avahi-daemon.service
  • Loading branch information
lathiat committed Mar 10, 2022
1 parent a91d3d4 commit 8465c3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/CONT/LXC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sub check {
}

# look for LXC cgroups
return unless($cg =~ /^\d+:[^:]+:\/lxc(?:.payload)?[.\/]([^\/\n]+)($|\/)/m);
return unless($cg =~ /^\d+:[^:]*:\/lxc(?:.payload)?[.\/]([^\/\n]+)($|\/)/m);

my $name = $1;
my $type = ($self->{has_lxd} && -d qq($self->{lxd_container_path}/$name) ? 'LXD' : 'LXC');
Expand Down
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/CONT/machined.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sub check {
}

# look for machined cgroups
return 0 unless($cg =~ /^\d+:[^:]+:\/machine.slice\/machine-(.+)\.scope$/m);
return 0 unless($cg =~ /^\d+:[^:]*:\/machine.slice\/machine-(.+)\.scope$/m);

my $name = $1;
unless($norestart) {
Expand Down

0 comments on commit 8465c3e

Please sign in to comment.