[pve-devel] [RFC container] fix #2200: do not forcestop containers when rebooting host

Oguz Bektas o.bektas at proxmox.com
Tue May 7 17:19:52 CEST 2019


i know, that's why i asked if someone had a better patch. because i
tried something like this and couldn't get it to work:

```
if (defined($param->{forceStop}) {
    PVE::LXC::vm_stop($vmid, 1, $timeout)
} else {
    PVE::LXC::vm_stop($vmid, 0, $timeout)
}
```
since i guess we want vm_shutdown to not forcestop by default.
but it didn't work in my tests. maybe i missed something??

maybe it's a better idea to do it like this:

```
$param->{forceStop} = 0 if !defined($param->{forceStop})
PVE::LXC::vm_stop($vmid, $param->{forceStop}, $timeout
```

but i haven't tested this.


On Tue, May 07, 2019 at 04:57:51PM +0200, Thomas Lamprecht wrote:
> On 5/7/19 4:44 PM, Oguz Bektas wrote:
> > Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> > ---
> > 
> > so this is quite confusing... i'm not sure if this is a valid fix and
> > it probably doesn't make much sense... but this was the only way i got
> > the containers to shutdown gracefully when a reboot/shutdown command
> > was issued on host. i've tested this on a cluster with all the main
> > linux distro containers running on it. i noticed on my hardware it
> > takes maximum 2-3 seconds for a ct to go down when they are abruptly
> > killed before rebooting the host (never >3s). however with this patch
> > i noticed the cts are taking more time to shutdown (some ~6s, some
> > still ~3s).
> > 
> > can someone test this? maybe offer a better patch ? i tried some other
> > variants but they didn't work and this one was the most clear one 
> > (although not very nice looking or logical) that worked.
> > 
> >  src/PVE/API2/LXC/Status.pm | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
> > index 95775fe..5b67498 100644
> > --- a/src/PVE/API2/LXC/Status.pm
> > +++ b/src/PVE/API2/LXC/Status.pm
> > @@ -369,7 +369,11 @@ __PACKAGE__->register_method({
> >  
> >  		PVE::LXC::Config->check_lock($conf);
> >  
> > -		PVE::LXC::vm_stop($vmid, $param->{forceStop}, $timeout);
> > +		if ($param->{forceStop}) {
> > +		    PVE::LXC::vm_stop($vmid, 1, $timeout);
> > +		} else {
> > +		    PVE::LXC::vm_stop($vmid, 0, $timeout);
> > +		}
> 
> sorry, but that needs to be semantically equivalent, at least if
> vm_stop doesn't has a "not defined" check for force-stop, and thus
> would only do so if $force-stop is falsy but defined???
> 
> >  
> >  		return;
> >  	    };
> > 
> 




More information about the pve-devel mailing list