← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1849449] Re: get_link_id() traceback in case of non-existing interface is misleading

 

Reviewed:  https://review.opendev.org/690514
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=ecef65b9b51fc1bd684ca9eb72a024ee44ca9347
Submitter: Zuul
Branch:    master

commit ecef65b9b51fc1bd684ca9eb72a024ee44ca9347
Author: Rodolfo Alonso Hernandez <ralonsoh@xxxxxxxxxx>
Date:   Wed Oct 23 08:31:59 2019 +0000

    Do not use exceptions in get_link_id() to control the code flow
    
    Instead of using exceptions as control flow, check the Pyroute2 command
    result and only raise the Neutron exception if needed. This will also
    reduce the traceback log in case of raising NetworkInterfaceNotFound.
    
    Although in Python the use of exception for this is common, this is
    usually considered an antipattern.
    
    Change-Id: I0e8bb3b0f6a46f2bac75e38c6ac6cdd094247f89
    Closes-Bug: #1849449


** Changed in: neutron
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1849449

Title:
  get_link_id()  traceback in case of non-existing interface is
  misleading

Status in neutron:
  Fix Released

Bug description:
  When privileged.agent.linux.ip_lib.get_link_id() method does not find
  the interface, the traceback thrown is misleading: first the index
  error is logged and then NetworkInterfaceNotFound traceback. We can
  reduce this traceback to the main one avoiding the index error
  exception.

  Traceback (most recent call last):
    File "/usr/lib/python3.6/site-packages/neutron/privileged/agent/linux/ip_lib.py", line 246, in get_link_id
      return ip.link_lookup(ifname=device)[0]
  IndexError: list index out of range

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3.6/site-packages/oslo_privsep/daemon.py", line 449, in _process_cmd
      ret = func(*f_args, **f_kwargs)
    File "/usr/lib/python3.6/site-packages/neutron/privileged/agent/linux/ip_lib.py", line 53, in sync_inner
      return input_func(*args, **kwargs)
    File "/usr/lib/python3.6/site-packages/oslo_privsep/priv_context.py", line 247, in _wrap
      return func(*args, **kwargs)
    File "/usr/lib/python3.6/site-packages/neutron/privileged/agent/linux/ip_lib.py", line 406, in get_link_attributes
      link = _run_iproute_link("get", device, namespace)[0]
    File "/usr/lib/python3.6/site-packages/neutron/privileged/agent/linux/ip_lib.py", line 254, in _run_iproute_link
      idx = get_link_id(device, namespace)
    File "/usr/lib/python3.6/site-packages/neutron/privileged/agent/linux/ip_lib.py", line 248, in get_link_id
      raise NetworkInterfaceNotFound(device=device, namespace=namespace)
  neutron.privileged.agent.linux.ip_lib.NetworkInterfaceNotFound: Network interface tap46dac0f2-cb not found in namespace qdhcp-8c9e6c68-86ef-4bb0-b3fa-9a36a71d0ccb.

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1849449/+subscriptions


References