kytos / topology

Kytos Main Topology Network Application (NApp)
https://napps.kytos.io/kytos/topology
MIT License
0 stars 20 forks source link

Topology update through event sometimes triggers an exception #57

Open macartur opened 6 years ago

macartur commented 6 years ago

When that happens, the server must be restarted.


  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/antonio/new_kytos/lib/python3.6/site-packages/kytos-2018.1b2-py3.6.egg/kytos/core/helpers.py", line 71, in threaded_handler
    handler(*args)
  File "/home/antonio/new_kytos/var/lib/kytos/napps/kytos/topology/main.py", line 373, in add_links
    interface_a.update_link(link)
AttributeError: 'NoneType' object has no attribute 'update_link'

Exception in thread Thread-109:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/antonio/new_kytos/lib/python3.6/site-packages/kytos-2018.1b2-py3.6.egg/kytos/core/helpers.py", line 71, in threaded_handler
    handler(*args)
  File "/home/antonio/new_kytos/var/lib/kytos/napps/amlight/coloring/main.py", line 51, in topology_updated
    [l.as_dict() for l in topology.links.values()]
  File "/home/antonio/new_kytos/var/lib/kytos/napps/amlight/coloring/main.py", line 51, in <listcomp>
    [l.as_dict() for l in topology.links.values()]
  File "/home/antonio/new_kytos/lib/python3.6/site-packages/kytos-2018.1b2-py3.6.egg/kytos/core/link.py", line 89, in as_dict
    'endpoint_a': self.endpoint_a.as_dict(),
AttributeError: 'NoneType' object has no attribute 'as_dict'```
macartur commented 6 years ago

This issue was moved from kytos/kytos#720

hdiogenes commented 6 years ago

@beraldoleal, you said in the original ticket that "A link MUST HAVE two interfaces, so if is none, we should raise an exception." So I think the best solution is to make Kytos core raise a ValueError exception when a Link is initialized with None endpoints, and handle it here in topology.

beraldoleal commented 6 years ago

@hdiogenes ok, let's go with this solution.