[pve-devel] [PATCH ha-manager] is_node_shutdown: check for correct systemd targets

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Dec 20 07:49:27 CET 2016


On 12/19/2016 10:06 AM, Dietmar Maurer wrote:
>> -	$shutdown = 1 if ($line =~ m/shutdown\.target/);
>> +	$shutdown = 1 if ($line =~ m/(poweroff|halt)\.target/);
> I wonder if we can improve that regex, to prevent false positives
> if somebody defined a target like 'my-useless-poweroff.target'?
>
> For example:
>
>    $shutdown = 1 if ($line =~ m/^(poweroff|halt)\.target$/);
>
> would that work?

No, systemctl list-jobs has a format like:

> JOB UNIT TYPE  STATE
> 703 reboot.target start waiting
> 704 systemd-reboot.service start waiting
> 705 shutdown.target start waiting

I had this also in mind, my regex looks like:

  > $shutdown = 1 if ($line =~ m/^(\d)+ (poweroff|halt)\.target(\s)+/);

which works as expected as far as I've tested. I'll send a v2 with this 
regex.




More information about the pve-devel mailing list