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

Oguz Bektas o.bektas at proxmox.com
Tue May 7 16:44:25 CEST 2019


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);
+		}
 
 		return;
 	    };
-- 
2.11.0





More information about the pve-devel mailing list