kytos-ng / of_core

Kytos Main OpenFlow Network Application (NApp)
MIT License
0 stars 5 forks source link

Interface custom `speed` isn't being set in certain port status cases #132

Closed viniarck closed 6 months ago

viniarck commented 6 months ago

Interface with speed none after re connection and/or when a new interface gets created with OFPPR_ADD (such as a logical that is dynamically created), currently the runtime is prepared to have speed:float = None, but topology datamodel isn't, we could also allow it there, but if you analyze the code, it's always possible to derive the current speed with OpenFlow messages, however, we're not setting the fallback speed when handling a port status in certain cases

2024-03-01 14:36:42,274 - ERROR [kytos.core.helpers] [helpers.py:151:handler_context_apm] (thread_pool_app_388) listen_to handler:
 <function Main.on_new_switch at 0x7fb04e1e2940>, args: (<Main(topology, stopped 140390024083200)>, KytosEvent('kytos/core.switch.
reconnected', {'switch': Switch('00:00:00:00:00:20:00:01')}, 0)) traceback: Traceback (most recent call last):,   File "/usr/local
/lib/python3.9/dist-packages/kytos/core/helpers.py", line 146, in handler_context_apm,     result = handler(*args),   File "//var/
lib/kytos/napps/kytos/topology/main.py", line 650, in on_new_switch,     self.handle_new_switch(event),   File "//var/lib/kytos/na
pps/kytos/topology/main.py", line 656, in handle_new_switch,     self.topo_controller.upsert_switch(switch.id, switch.as_dict()),
  File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 324, in wrapped_f,     return self(f, *args, **kw),   F
ile "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 404, in __call__,     do = self.iter(retry_state=retry_sta
te),   File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 349, in iter,     return fut.result(),   File "/us
r/lib/python3.9/concurrent/futures/_base.py", line 433, in result,     return self.__get_result(),   File "/usr/lib/python3.9/conc
urrent/futures/_base.py", line 389, in __get_result,     raise self._exception,   File "/usr/local/lib/python3.9/dist-packages/ten
acity/__init__.py", line 407, in __call__,     result = fn(*args, **kwargs),   File "/usr/local/lib/python3.9/dist-packages/kytos/
core/retry.py", line 25, in decorated,     return func(*args, **kwargs),   File "//var/lib/kytos/napps/../napps/kytos/topology/con
trollers/__init__.py", line 110, in upsert_switch,     model = SwitchDoc(,   File "pydantic/main.py", line 331, in pydantic.main.B
aseModel.__init__, pydantic.error_wrappers.ValidationError: 1 validation error for SwitchDoc, interfaces -> 39 -> speed,   none is
 not an allowed value (type=type_error.none.not_allowed),

This is an issue that @italovalcy and @renatafrez has caught in prod

Priority major since it can crash and impact on a DB write