kill_dhcp fails if dnsmasq is not running

Bug #943690 reported by JC Martin on 2012-03-01
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Low
JC Martin

Bug Description

in nova/network/linux_net.py

If dnsmasq is not running, the following line :

    pid = _dnsmasq_pid_for(dev)

returns NONE.
Since
   _execute('kill', '-9', pid, run_as_root=True)

doesn't check for None, this cause the following exception:

Command: sudo nova-rootwrap kill -9 None
Exit code: 99
Stdout: 'Unauthorized command: kill -9 None\n'
Stderr: ''
(nova): TRACE: Traceback (most recent call last):
(nova): TRACE: File "/usr/bin/nova-manage", line 2372, in <module>
(nova): TRACE: main()
(nova): TRACE: File "/usr/bin/nova-manage", line 2360, in main
(nova): TRACE: fn(*fn_args, **fn_kwargs)
(nova): TRACE: File "/usr/bin/nova-manage", line 908, in delete
(nova): TRACE: fixed_range, uuid)
(nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/quantum/manager.py", line 251, in delete_network
(nova): TRACE: self.driver.kill_dhcp(dev)
(nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 661, in kill_dhcp
(nova): TRACE: _execute('kill', '-9', pid, run_as_root=True)
(nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 818, in _execute
(nova): TRACE: return utils.execute(*cmd, **kwargs)
(nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/utils.py", line 225, in execute
(nova): TRACE: cmd=' '.join(cmd))
(nova): TRACE: ProcessExecutionError: Unexpected error while running command.
(nova): TRACE: Command: sudo nova-rootwrap kill -9 None
(nova): TRACE: Exit code: 99
(nova): TRACE: Stdout: 'Unauthorized command: kill -9 None\n'
(nova): TRACE: Stderr: ''
(nova): TRACE:

simple fix is:

def kill_dhcp(dev):
    pid = _dnsmasq_pid_for(dev)
    if pid is not None:
       _execute('kill', '-9', pid, run_as_root=True)

aswinnair (aswin) wrote :

Are you sure you are running the latest version of Nova ?

Thierry Carrez (ttx) wrote :

@JCMartin: would you consider filing the patch to Gerrit, or should I on your behalf ?

Changed in nova:
importance: Undecided → Low
status: New → Triaged

I'll try it: it's simple enough that I'm unlikely to break something else.

jc

Sent from my iPhone

On Mar 1, 2012, at 2:43 AM, "Thierry Carrez" <email address hidden> wrote:

> @JCMartin: would you consider filing the patch to Gerrit, or should I on
> your behalf ?
>
> ** Changed in: nova
> Importance: Undecided => Low
>
> ** Changed in: nova
> Status: New => Triaged
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/943690
>
> Title:
> kill_dhcp fails if dnsmasq is not running
>
> Status in OpenStack Compute (Nova):
> Triaged
>
> Bug description:
> in nova/network/linux_net.py
>
> If dnsmasq is not running, the following line :
>
> pid = _dnsmasq_pid_for(dev)
>
> returns NONE.
> Since
> _execute('kill', '-9', pid, run_as_root=True)
>
> doesn't check for None, this cause the following exception:
>
> Command: sudo nova-rootwrap kill -9 None
> Exit code: 99
> Stdout: 'Unauthorized command: kill -9 None\n'
> Stderr: ''
> (nova): TRACE: Traceback (most recent call last):
> (nova): TRACE: File "/usr/bin/nova-manage", line 2372, in <module>
> (nova): TRACE: main()
> (nova): TRACE: File "/usr/bin/nova-manage", line 2360, in main
> (nova): TRACE: fn(*fn_args, **fn_kwargs)
> (nova): TRACE: File "/usr/bin/nova-manage", line 908, in delete
> (nova): TRACE: fixed_range, uuid)
> (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/quantum/manager.py", line 251, in delete_network
> (nova): TRACE: self.driver.kill_dhcp(dev)
> (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 661, in kill_dhcp
> (nova): TRACE: _execute('kill', '-9', pid, run_as_root=True)
> (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/network/linux_net.py", line 818, in _execute
> (nova): TRACE: return utils.execute(*cmd, **kwargs)
> (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/utils.py", line 225, in execute
> (nova): TRACE: cmd=' '.join(cmd))
> (nova): TRACE: ProcessExecutionError: Unexpected error while running command.
> (nova): TRACE: Command: sudo nova-rootwrap kill -9 None
> (nova): TRACE: Exit code: 99
> (nova): TRACE: Stdout: 'Unauthorized command: kill -9 None\n'
> (nova): TRACE: Stderr: ''
> (nova): TRACE:
>
>
> simple fix is:
>
>
> def kill_dhcp(dev):
> pid = _dnsmasq_pid_for(dev)
> if pid is not None:
> _execute('kill', '-9', pid, run_as_root=True)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nova/+bug/943690/+subscriptions

Fix proposed to branch: master
Review: https://review.openstack.org/4819

Changed in nova:
assignee: nobody → JC Martin (jemartin)
status: Triaged → In Progress

Reviewed: https://review.openstack.org/4819
Committed: http://github.com/openstack/nova/commit/dab9de9357567bec845c1ac050b88ca07fe09217
Submitter: Jenkins
Branch: master

commit dab9de9357567bec845c1ac050b88ca07fe09217
Author: JC Martin <email address hidden>
Date: Thu Mar 1 18:52:29 2012 -0800

    Do not invoke kill dnsmasq if no pid file was found.

    fixes Bug 943690

    Change-Id: I2b1f5cc66ba6ef02219c0d4445487bdd3a541f4b

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-03-20
Changed in nova:
milestone: none → essex-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-rc1 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers