Un-graceful shutdown of container hangs PVE reboot

AdamWu

New Member
Feb 13, 2018
2
1
1
42
Currently at PVE shutdown/reboot, the CTs are forced immediate ungraceful shutdown with --kill.
This is a bit unexpected since the host is having a graceful shutdown, one would expect the containers to do the same.

And in scenario with CIFS network mounts, this is actually making host shutdown MUCH SLOWER than needed.
Because everything is killed instantly, all networking in the CT is gone before umount can finish.
But lxc does not consider shutdown complete until all mounts are removed.
So then lxc-stop hangs for 120 seconds, until the kernel cifs module timeout, then finally return.

I haven't tested with other types of network mounts, but it seems they are more-or-less susecptible to this problem.
 
The following patch seems to fix the problem:

Code:
File: /usr/share/perl5/PVE/API2/LXC/Status.pm:

Replace:
                PVE::LXC::vm_stop($vmid, $param->{forceStop}, $timeout);

With:
                PVE::LXC::vm_stop($vmid, 0, $timeout);
                if ($param->{forceStop}) {
                    PVE::LXC::vm_stop($vmid, 1);
                }
 
  • Like
Reactions: wasp
I have also the problem, that the LXC Containers are not gracefully stopped - this is not exactly an issue with NFS or CIFS and rather happens to every LXC Container i run.

This is pretty annoying i.e. when using mysql inside a container which is never cleanly stopped when the host issues a reboot. Is there a way to tell proxmox to issue a shutdown command to the LXC instead of the stop command?
 
I have also the problem, that the LXC Containers are not gracefully stopped - this is not exactly an issue with NFS or CIFS and rather happens to every LXC Container i run.

How do you stop your containers? Are you using
Code:
pct shutdown CTID

Because that's the way to trigger clean shutdowns instead of killing the processes.

From `man pct`:

Code:
pct stop <vmid> [OPTIONS]

       Stop the container. This will abruptly stop all processes running in the container.

       <vmid>: <integer> (1 - N)
           The (unique) ID of the VM.

       --skiplock <boolean>
           Ignore locks - only root is allowed to use this option.



.
.
.


pct shutdown <vmid> [OPTIONS]

       Shutdown the container. This will trigger a clean shutdown of the container, see lxc-stop(1) for details.

       <vmid>: <integer> (1 - N)
           The (unique) ID of the VM.

       --forceStop <boolean> (default = 0)
           Make sure the Container stops.

       --timeout <integer> (0 - N) (default = 60)
           Wait maximal timeout seconds.
 
@oguz:

i think you got me wrong. I do know how to cleanly shutdown containers, which works very well from the CLI as well as the Web-GUI: when issuing the shutdown from within the Web-GUI it sends "pct shutdown" to the selected container.

But the issue is: if for whatever reason the host is rebooted (via Web-GUI, bash, or any other method) proxmox tries to shutdown all machines. VMs (KVM-Qemu) are brought down via a "shutdown" but LXC-Containers are simply stopped without issuing a "shutdown" command.

That's the bug i am talking about - there should be no reason for the proxmox scripts to issue the "stop" command during shutdown/reboot of the host and instead it should use "shutdown" for both qemu as well as LXC.

I hope this will get fixed in the future.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!