kytos-ng / sdntrace

Napp that traces OpenFlow paths in the dataplane
https://kytos-ng.github.io/api/sdntrace.html
GNU Lesser General Public License v3.0
0 stars 5 forks source link

bug: after a controller restart, if a given switch hasn't connected yet, trace results in exc trying to derive OpenFlow version #66

Open viniarck opened 2 months ago

viniarck commented 2 months ago

Expected behavior: A trace id should be returned but it shouldn't result in an exception.

How to reproduce

❯ echo '{ "trace": { "switch": { "dpid": "00:00:00:00:00:00:00:01", "in_port": 1}, "eth": {"dl_type": 2048, "dl_vlan": 2222}, "ip": { "nw_proto": 6 } } }' | http PUT http://127.0.0.1:8181/api/amlight/sdntrace/trace

Check out the

kytos $> controller.switches['00:00:00:00:00:00:00:01'].features

kytos $> controller.switches['00:00:00:00:00:00:00:01'].connection

kytos $> 

kytos $> controller.switches['00:00:00:00:00:00:00:01'].is_active()
Out[4]: False

kytos $> 2024-04-09 15:41:59,819 - INFO [uvicorn.access] (MainThread) 127.0.0.1:34918 - "GET /api/amlight/coloring/colors HTTP/1.1" 200
2024-04-09 15:41:59,821 - INFO [uvicorn.access] (MainThread) 127.0.0.1:34932 - "GET /api/amlight/coloring/colors HTTP/1.1" 200
2024-04-09 15:41:59,821 - INFO [uvicorn.access] (MainThread) 127.0.0.1:34908 - "PUT /api/amlight/sdntrace/trace HTTP/1.1" 200
2024-04-09 15:42:00,007 - INFO [kytos.napps.amlight/sdntrace] (Dummy-90) Creating thread to trace request id 30001...
2024-04-09 15:42:00,008 - WARNING [kytos.napps.amlight/sdntrace] (Dummy-90) Starting Trace Path ID: 30001
2024-04-09 15:42:00,014 - INFO [uvicorn.access] (MainThread) 127.0.0.1:34938 - "GET /api/amlight/coloring/colors HTTP/1.1" 200
2024-04-09 15:42:00,019 - INFO [uvicorn.access] (MainThread) 127.0.0.1:34948 - "GET /api/amlight/coloring/colors HTTP/1.1" 200
2024-04-09 15:42:00,021 - WARNING [kytos.napps.amlight/sdntrace] (Dummy-90) Trace 30001: Sending POut to switch: 00:00:00:00:00:00:00:01 and in_port 1 
Exception ignored in thread started by: <bound method TraceManager._spawn_trace of <napps.amlight.sdntrace.tracing.trace_manager.TraceManager object at 0x7f4af04c1610>>
Traceback (most recent call last):
  File "/home/viniarck/repos/napps/napps/amlight/sdntrace/tracing/trace_manager.py", line 95, in _spawn_trace
    tracer.tracepath()
  File "/home/viniarck/repos/napps/napps/amlight/sdntrace/tracing/tracer.py", line 83, in tracepath
    self.tracepath_loop(entries, color, switch)
  File "/home/viniarck/repos/napps/napps/amlight/sdntrace/tracing/tracer.py", line 102, in tracepath_loop
    result, packet_in = self.send_trace_probe(switch, in_port,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/viniarck/repos/napps/napps/amlight/sdntrace/tracing/tracer.py", line 141, in send_trace_probe
    send_packet_out(self.trace_mgr.controller,
  File "/home/viniarck/repos/napps/napps/amlight/sdntrace/backends/of_parser.py", line 39, in send_packet_out
    of_version = switch.features.header.version
                 ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'header'