Bug#595926: invoke-rc.d lxc stop should provide a way to gracefully terminate containers

2010-09-27 Thread Konstantin Khomoutov
On Sat, 25 Sep 2010 11:13:22 +0200
Mike Hommey m...@glandium.org wrote:

 On Tue, Sep 07, 2010 at 03:13:26PM +0400, Konstantin Khomoutov wrote:

  Currently, LXC init script is able to start the configured set of
  containers (which is very convenient) but to stop them it uses
  lxc-stop which merely kills the set of processes belonging to a
  container. When a container has its own rootfs with a system
  created using debootstrap or similar means, it is expected that the
  stop action should be similar to start, that is, something like
  `shutdown -h +0` or `telinit 0` should be executed inside such
  containers, and then they should be waited upon to terminate.
[...]
 Without lxc-attach, you can still use a workaround, provided your
 containers have a proper /dev/initctl and /sbin/telinit works: You can
 chroot $container_root telinit 0

Just verified on a test container -- it works.
Thanks, Mike!

While I think that having lxc-attach working is a must as Debian ships
an LXC-enabled kernel, for now this workaround can be implemented in the
lxc package as is.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#595926: invoke-rc.d lxc stop should provide a way to gracefully terminate containers

2010-09-25 Thread Mike Hommey
On Tue, Sep 07, 2010 at 03:13:26PM +0400, Konstantin Khomoutov wrote:
 Package: lxc
 Version: 0.7.2-1
 Severity: normal
 
 Currently, LXC init script is able to start the configured set of
 containers (which is very convenient) but to stop them it uses lxc-stop
 which merely kills the set of processes belonging to a container.
 When a container has its own rootfs with a system created using
 debootstrap or similar means, it is expected that the stop action
 should be similar to start, that is, something like `shutdown -h +0`
 or `telinit 0` should be executed inside such containers, and then
 they should be waited upon to terminate.
 
 As I understand, the following sequence should work:
 
 for cont in $CONTAINERS; do
   lxc-attach -n $cont 'shutdown -h +0' \
  lxc-wait -n $cont -s STOPPED \
  lxc-stop -n $cont
 done
 
 The actual code can become more involved as ideally the init script should
 wait for some grace period for the containers to shut down
 and then use lxc-stop on the remaining containers forcibly.
 I assume the implementation details are open for discussion.
 
 Also, since containers are not required to virtualise a whole OS
 on its own rootfs and may be used to host just one process or a bunch
 of processes, there should be a way to mark container explicitly
 as requiring a graceful shutdown.
 Another possibility would be to specify a command to issue inside
 a container to shut it down; an empty command (the default) could
 signalize no graceful shutdown is required. This method would put more
 burden on the administrator but is more flexible.
 
 In any case, implementing this functionality depends on making
 lxc-attach working, and I filed bug #595920 for this reason.

Without lxc-attach, you can still use a workaround, provided your
containers have a proper /dev/initctl and /sbin/telinit works: You can
chroot $container_root telinit 0

Mike



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#595926: invoke-rc.d lxc stop should provide a way to gracefully terminate containers

2010-09-07 Thread Konstantin Khomoutov
Package: lxc
Version: 0.7.2-1
Severity: normal

Currently, LXC init script is able to start the configured set of
containers (which is very convenient) but to stop them it uses lxc-stop
which merely kills the set of processes belonging to a container.
When a container has its own rootfs with a system created using
debootstrap or similar means, it is expected that the stop action
should be similar to start, that is, something like `shutdown -h +0`
or `telinit 0` should be executed inside such containers, and then
they should be waited upon to terminate.

As I understand, the following sequence should work:

for cont in $CONTAINERS; do
  lxc-attach -n $cont 'shutdown -h +0' \
 lxc-wait -n $cont -s STOPPED \
 lxc-stop -n $cont
done

The actual code can become more involved as ideally the init script should
wait for some grace period for the containers to shut down
and then use lxc-stop on the remaining containers forcibly.
I assume the implementation details are open for discussion.

Also, since containers are not required to virtualise a whole OS
on its own rootfs and may be used to host just one process or a bunch
of processes, there should be a way to mark container explicitly
as requiring a graceful shutdown.
Another possibility would be to specify a command to issue inside
a container to shut it down; an empty command (the default) could
signalize no graceful shutdown is required. This method would put more
burden on the administrator but is more flexible.

In any case, implementing this functionality depends on making
lxc-attach working, and I filed bug #595920 for this reason.


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages lxc depends on:
ii  libc6 2.11.2-2   Embedded GNU C Library: Shared lib
ii  libcap2   1:2.19-3   support for getting/setting POSIX.

Versions of packages lxc recommends:
ii  libcap2-bin   1:2.19-3   basic utility programs for using c

lxc suggests no packages.

-- Configuration Files:
/etc/default/lxc changed:
RUN=yes
CONF_DIR=/etc/lxc
CONTAINERS=bender


-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org