on_openflow_connection_error should gracefully handle when a switch hasn't been created yet. It turns out that a kytos/core.openflow.connection.error can also be sent while FeaturesReply hasn't been received yet, so the switch doesn't exist. When that's the case, then there's no multipart_replies_xids to be handled, so this handler needs to check if the switch exist.
This case was caught on e2e tests:
Apr 11 16:03:30 runner-rmtk68xb-project-107-concurrent-0 2023-04-11 16:03:30,304 (MainThread) kytos.core.helpers:ERROR helpers:230: alisten_to handler: <function Main.on_openflow_connection_error at 0x7f10d41e0ca0>, args: (<Main(of_core, started 139709447567104)>, KytosEvent('kytos/core.openflow.connection.error', {'message': FeaturesRequest(xid=2673180190), 'destination': Connection('127.0.0.1', 33010, <asyncio.TransportSocket fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>, None, <ConnectionState.FINISHED: 4>), 'exception': 'Connection state: ConnectionState.FINISHED'}, -1099)) traceback: Traceback (most recent call last):, File "/usr/local/lib/python3.9/dist-packages/kytos/core/helpers.py", line 226, in handler_context, result = await handler(*args), File "//var/lib/kytos/napps/kytos/of_core/main.py", line 513, in on_openflow_connection_error, self.pop_multipart_replies(event.content["destination"].switch), File "//var/lib/kytos/napps/kytos/of_core/main.py", line 506, in pop_multipart_replies, self._multipart_replies_xids.pop(switch.id, None), AttributeError: 'NoneType' object has no attribute 'id',
on_openflow_connection_error
should gracefully handle when a switch hasn't been created yet. It turns out that akytos/core.openflow.connection.error
can also be sent whileFeaturesReply
hasn't been received yet, so the switch doesn't exist. When that's the case, then there's nomultipart_replies_xids
to be handled, so this handler needs to check if the switch exist.This case was caught on e2e tests: