kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
2 stars 7 forks source link

fix: avoid `kytosd` hanging its termination when handling `SystemExit` with SIGTERM #426

Closed viniarck closed 8 months ago

viniarck commented 8 months ago

Closes #424

Summary

See updated changelog

Local Tests

Here's the same exec with the reported issue:

2023-10-25 09:52:17,053 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/amlight/sdntrace_cp/v1/trace - PUT
2023-10-25 09:52:17,053 - INFO [kytos.core.api_server] [api_server.py:429:_start_endpoint] (MainThread) Started /api/amlight/sdntrace_cp/v1/traces - PUT
2023-10-25 09:52:17,053 - INFO [kytos.core.controller] [controller.py:847:load_napps] (MainThread) Loading NApp amlight/noviflow
2023-10-25 09:52:17,056 - INFO [kytos.core.napps.base] [base.py:248:run] (noviflow) Running NApp: <Main(noviflow, started 140440724563648)>
2023-10-25 09:52:17,056 - INFO [kytos.core.controller] [controller.py:847:load_napps] (MainThread) Loading NApp kytos/mef_eline
2023-10-25 09:52:17,270 - INFO [apscheduler.scheduler] [base.py:171:start] (MainThread) Scheduler started
Kytos couldn't start because of KytosNAppSetupException: NApp kytos/mef_eline exception some err  Traceback (most recent call last):
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 813, in load_napp
    napp = napp_module.Main(controller=self)
  File "/home/viniarck/repos/kytos/kytos/core/napps/base.py", line 194, in __init__
    self.setup()
  File "/home/viniarck/repos/napps/napps/kytos/mef_eline/main.py", line 66, in setup
    raise ValueError("some err")
ValueError: some err

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 262, in start
    self.start_controller()
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 358, in start_controller
    self.load_napps()
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 848, in load_napps
    self.load_napp(napp.username, napp.name)
  File "/home/viniarck/repos/kytos/kytos/core/controller.py", line 816, in load_napp
    raise KytosNAppSetupException(msg) from exc
kytos.core.exceptions.KytosNAppSetupException: KytosNAppSetupException: NApp kytos/mef_eline exception some err 

Shutting down Kytos...
[1]    28495 terminated  kytosd -f --database mongodb -E

End-to-End Tests

plugins: rerunfailures-10.2, timeout-2.1.0, anyio-3.6.2
collected 242 items
tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
tests/test_e2e_05_topology.py ..................                         [  8%]
tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 24%]
tests/test_e2e_11_mef_eline.py ......                                    [ 27%]
tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 30%]
tests/test_e2e_13_mef_eline.py ....Xs.s.....Xs.s.XXxX.xxxx..X........... [ 47%]
.                                                                        [ 47%]
tests/test_e2e_14_mef_eline.py x                                         [ 48%]
tests/test_e2e_15_mef_eline.py ....                                      [ 50%]
tests/test_e2e_20_flow_manager.py .....................                  [ 58%]
tests/test_e2e_21_flow_manager.py ...                                    [ 59%]
tests/test_e2e_22_flow_manager.py ...............                        [ 66%]
tests/test_e2e_23_flow_manager.py ..............                         [ 71%]
tests/test_e2e_30_of_lldp.py ....                                        [ 73%]
tests/test_e2e_31_of_lldp.py ...                                         [ 74%]
tests/test_e2e_32_of_lldp.py ...                                         [ 76%]
tests/test_e2e_40_sdntrace.py .............                              [ 81%]
tests/test_e2e_41_kytos_auth.py ........                                 [ 84%]
tests/test_e2e_50_maintenance.py ........................                [ 94%]
tests/test_e2e_60_of_multi_table.py .....                                [ 96%]
tests/test_e2e_70_kytos_stats.py ........                                [100%]
=============================== warnings summary ===============================
------------------------------- start/stop times -------------------------------
= 220 passed, 6 skipped, 9 xfailed, 7 xpassed, 867 warnings in 11640.76s (3:14:00) =