[pve-devel] [PATCH container 2/2] vm_stop: add nokill-after-timeout parameter
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu May 9 19:11:28 CEST 2019
On 5/9/19 7:11 PM, Oguz Bektas wrote:
> looks like we have a race in lxc-stop in some cases, will look into it
> later but it seems to be functioning properly.
yeah, the:
> lxc-stop: 114: commands_utils.c: lxc_cmd_sock_rcv_state: 70 Resource temporarily unavailable - Failed to receive message
message one gets if the CT shutdown with kill-after-timeout runs into
the timeout, but that was already present before this patches and should
be an LXC internal issue.
> > tested series, everything looks fine.
>
> Tested-by: Oguz Bektas <o.bektas at proxmox.com>
much thanks for looking at it!
>
> On Wed, May 08, 2019 at 02:02:43PM +0200, Thomas Lamprecht wrote:
>> On 5/8/19 1:58 PM, Thomas Lamprecht wrote:
>>> This allows to have the same semantics as qemu-server:
>>> * immediate hard-kill
>>> * shutdown with kill after timeout
>>> * shutdown without kill after timeout
>>>
>>> And thus we finally can move the vm_shutdown API call to a correct
>>> semantic, i.e., do not immediate hard kill if forceStop is not passed
>>> but rather see it as stop after timeout knob.
>>>
>>> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
>>
>> forgot: fixes #2200
>>
>>> ---
>>> src/PVE/API2/LXC/Status.pm | 2 +-
>>> src/PVE/LXC.pm | 18 +++++++++++++-----
>>> 2 files changed, 14 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
>>> index 95775fe..f6668e2 100644
>>> --- a/src/PVE/API2/LXC/Status.pm
>>> +++ b/src/PVE/API2/LXC/Status.pm
>>> @@ -369,7 +369,7 @@ __PACKAGE__->register_method({
>>>
>>> PVE::LXC::Config->check_lock($conf);
>>>
>>> - PVE::LXC::vm_stop($vmid, $param->{forceStop}, $timeout);
>>> + PVE::LXC::vm_stop($vmid, 0, $timeout, !$param->{forceStop});
>>>
>>> return;
>>> };
>>> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
>>> index f8fc37e..5d099ca 100644
>>> --- a/src/PVE/LXC.pm
>>> +++ b/src/PVE/LXC.pm
>>> @@ -1938,8 +1938,11 @@ sub vm_start {
>>> # This is necessary because we want the post-stop hook to have completed its
>>> # unmount-all step, but post-stop happens after lxc puts the container into the
>>> # STOPPED state.
>>> +# $kill - if true it will always do an immediate hard-stop
>>> +# $shutdown_timeout - the timeout to wait for a gracefull shutdown
>>> +# $nokill_after_timeout - if true, do not send a hardstop if shutdown timed out
>>> sub vm_stop {
>>> - my ($vmid, $kill, $shutdown_timeout) = @_;
>>> + my ($vmid, $kill, $shutdown_timeout, $nokill_after_timeout) = @_;
>>>
>>> # Open the container's command socket.
>>> my $path = "\0/var/lib/lxc/$vmid/command";
>>> @@ -1961,10 +1964,15 @@ sub vm_stop {
>>>
>>> if ($kill) {
>>> push @$cmd, '--kill'; # doesn't allow timeouts
>>> - } elsif (defined($shutdown_timeout)) {
>>> - push @$cmd, '--timeout', $shutdown_timeout;
>>> - # Give run_command 5 extra seconds
>>> - $shutdown_timeout += 5;
>>> + } else {
>>> + # lxc-stop uses a default timeout
>>> + push @$cmd, '--nokill' if $nokill_after_timeout;
>>> +
>>> + if (defined($shutdown_timeout)) {
>>> + push @$cmd, '--timeout', $shutdown_timeout;
>>> + # Give run_command 5 extra seconds
>>> + $shutdown_timeout += 5;
>>> + }
>>> }
>>>
>>> eval { PVE::Tools::run_command($cmd, timeout => $shutdown_timeout) };
>>>
>>
>>
>> _______________________________________________
>> pve-devel mailing list
>> pve-devel at pve.proxmox.com
>> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
More information about the pve-devel
mailing list