sudo restart lxc-net does not kill/restart dnsmasq

Bug #1043588 reported by Scott Moser
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Confirmed
Medium
Unassigned
Precise
Triaged
Low
Unassigned
Quantal
Triaged
Low
Unassigned

Bug Description

$ ps axw | grep dnsm
14672 ? S 0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/lxc/dnsmasq.pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0

$ sudo vi /etc/init/lxc-net.conf
# change parameters for dnsmasq

$ sudo restart lxc-net
$ ps axw | grep dnsm
14672 ? S 0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/lxc/dnsmasq.pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0

^^ Note, restart did not get new dnsmasq pid or settings

$ sudo stop lxc-net
lxc-net stop/waiting
$ sudo start lxc-net
lxc-net start/running
$ ps axw | grep dnsm
14672 ? S 0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/lxc/dnsmasq.pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0

## Note stop, start did not get new dnsmasq settings

$ sudo stop lxc-net
$ sudo kill 14672
$ sudo start lxc-net
lxc-net start/running
$ ps axw | grep dnsm
32299 pts/0 S+ 0:00 grep --color=auto dnsm

## Note, no dnsmasq was started

$ sudo reboot
## on reboot new settings will take affect

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: lxc 0.7.5-3ubuntu62
ProcVersionSignature: User Name 3.2.0-29.46-virtual 3.2.24
Uname: Linux 3.2.0-29-virtual x86_64
ApportVersion: 2.0.1-0ubuntu12
Architecture: amd64
Date: Thu Aug 30 01:04:46 2012
Ec2AMI: ami-0000013e
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.small
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
ProcEnviron:
 TERM=screen
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: lxc
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.init.lxc.net.conf: [modified]
mtime.conffile..etc.init.lxc.net.conf: 2012-08-30T01:03:44.536628

Revision history for this message
Scott Moser (smoser) wrote :
Revision history for this message
James Page (james-page) wrote :

Scott

I can reproduce the restart issue, but using start/stop dnsmasq was restarted:

ubuntu@server-15281:~$ ps axw | grep dnsm
 5367 ? S 0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/lxc/dnsmasq.pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0
ubuntu@server-15281:~$ sudo stop lxc-net
lxc-net stop/waiting
ubuntu@server-15281:~$ ps axw | grep dnsm
 5409 pts/0 S+ 0:00 grep --color=auto dnsm
ubuntu@server-15281:~$ sudo start lxc-net
lxc-net start/running
ubuntu@server-15281:~$ ps axw | grep dnsm
 5425 ? S 0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/lxc/dnsmasq.pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0

I did get confused by the duplicated configuration entries for network ranges in /etc/default/lxc and /etc/init/lxc-net.conf.

Marking 'Low' as I think it only impacts the restart case - which can be worked around using stop/start lxc-net.

Changed in lxc (Ubuntu):
status: New → Confirmed
importance: Undecided → Low
status: Confirmed → Triaged
Changed in lxc (Ubuntu Precise):
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Thanks for reporting this bug. This is actually a bug in upstart, not lxc, reported as bug 703800. I'll mark it as a duplicate.

Revision history for this message
John Neffenger (jgneff) wrote :

In my tests on Ubuntu 14.04, the LXC dnsmasq process is restarted with:

$ sudo restart lxc-net

only when all guest containers are stopped. If one or more containers are running, the dnsmasq process is left running with its old settings when lxc-net is restarted.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 1043588] Re: sudo restart lxc-net does not kill/restart dnsmasq

This happens because 'restart service' does not cause service's post-stop
to be executed. Only it's pre-stop is executed.

Note that if you want to stop the dnsmasq, you can work around this by
doing

stop lxc-net; start lxc-net

The pre-start also would not be executed on a restart, so just changing
the post-stop would not suffice. We'd have to change the pre-start to
'script'.

I'm not sure whether there is any downside to doing so.

 status: confirmed
 importance: medium

Changed in lxc (Ubuntu):
importance: Low → Medium
status: Triaged → Confirmed
Revision history for this message
Pablo RUTH (d-contact-a) wrote :

@jneff yes the same for me, so the workaround doesn't work... because the post-stop script try do delete the bridge but there is an error "bridge lxcbr0 is still up; can't delete it" if all containers are not stopped. After that if you try so start lxc-net there is a test "if [ -d /sys/class/net/${LXC_BRIDGE} ]; then" so as the bridge is already up the script exit and will not launch dnsmasq... I'm right?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.