Bug 1138528 - lxc-stop not working as expected
Summary: lxc-stop not working as expected
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: lxc
Version: epel7
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Thomas Moschny
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-05 05:46 UTC by Sklav
Modified: 2014-09-17 01:30 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-09-17 01:30:09 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Sklav 2014-09-05 05:46:34 UTC
Description of problem:

lxc-stop does not stop all types of containers. Example debian wheezy containers do not stop properly and are killed after 60 second timeout

Version-Release number of selected component (if applicable):

lxc-1.0.5-3.el7.x86_64

How reproducible:
On 2 different installs i have the same issue with debian containers running on centos 7

Steps to Reproduce:
1. lxc-stop -n container_name

Actual results:
container stops running after a delay of approx 60 seconds

Expected results:
container should stop running immediately or withing a few seconds aka less than 2 or 3 seconds

lxc-stop -n container_name -k    seems to work but from what i understand this forces a shutdown similar to cutting the power

Additional info:
Very annoying issue as in many cases it looks like the container has locked up

This causes issues if you ever reboot the host machine as it takes a few minutes if not more to power cycle

Comment 1 Michael H. Warfield 2014-09-14 18:10:43 UTC
This is an issue with SIGPWR handling in the container.  The lxc-stop command now issues a SIGPWR signal to the container init and then waits a time out period for the container to gracefully shut down and exit.  The container init process must handle that signal and shut down gracefully.  If it fails to shut down gracefully before a timeout, lxc-stop will then kill the container.

The Debian container (probably sysvinit or lsbinit) has to be configured to handle the SIGPWR signal an initiate a shutdown.  Alternative is to simply issue a "lxc-stop -k" or set a very short timeout.  But this doesn't do and orderly shutdown in the container.  The proper solution is to reconfigure the Debian container to shut down on SIGPWR.

That can probably (should probably) be set up in the Debian template but all existing (old) containers will have to be reconfigured manually.

The old behavior of lxc-stop pre-1.0 was to unceremoniously kill the container, which can lead to corrupted database and other mayhem from the container not shutting down gracefully.  The current lxc-stop is behaving as designed and as expected.  The problem is a configuration issue in the container.

Comment 2 Michael H. Warfield 2014-09-15 00:19:37 UTC
Strange...  I just now tested a Debian Wheezy container on my Fedora 20 server.  Running lxc-stop -n {container} shuts the container down in about 3 or 4 seconds, no problem.

Does your container have this line in /etc/inittab?

p0::powerfail:/sbin/init 0

Did you install and alternate init system (upstart or systemd)?

Comment 3 Sklav 2014-09-17 01:24:39 UTC
I can confirm that on my template in inittab
p0::powerfail:/sbin/init 0
was not being added.

this is due to the containers having been migrated from an older lxc base. 

I have added it to existing containers and all is working as expected. So we can consider this resolved. Sorry for the inconvenience


Note You need to log in before you can comment on or make changes to this bug.