ecklm / adaptive-network-slicing

Project holding the implementation and results of my thesis project at University of Trento, Italy
20 stars 5 forks source link

Controller: Implement clearing rules from switches #13

Closed ecklm closed 4 years ago

ecklm commented 4 years ago

Problem

When I restart the controller with new flow configurations, the old flows remain in the switches, so I get stats to flows which are eventually not managed by the QoSManager. That causes an exception looking like this:

AdaptingMonitor13: Exception occurred during handler processing. Backtrace from offending handler [_flow_stats_reply_handler] servicing event [EventOFPFlowStatsReply] follows.
Traceback (most recent call last):
  File "/home/ecklm/Projects/Diploma/implementation/controller/.venv/lib/python3.8/site-packages/ryu/base/app_manager.py", line 290, in _event_loop
    handler(ev)
  File "/home/ecklm/Projects/Diploma/implementation/controller/adapting_monitor_13.py", line 133, in _flow_stats_reply_handler
    self.qos_managers[dpid].adapt_queues(self.stats[dpid].export_avg_speeds_bps())
  File "/home/ecklm/Projects/Diploma/implementation/controller/adapting_monitor_13.py", line 195, in adapt_queues
    unused_candidates = [k for k, v in flowstats.items() if v < self.FLOWS_INIT_LIMITS[k][0] / 2]
  File "/home/ecklm/Projects/Diploma/implementation/controller/adapting_monitor_13.py", line 195, in <listcomp>
    unused_candidates = [k for k, v in flowstats.items() if v < self.FLOWS_INIT_LIMITS[k][0] / 2]
KeyError: FlowId(ipv4_dst='10.0.0.1', udp_dst=5009)

For now, I intentionally don't catch this exception so that I don't suppress the problem.

Ideal solution

Ideally, deprecated flow rules should be cleared out from the switches.

ecklm commented 4 years ago

The rest_qos app offers DELETE operation for both rules and queues.

ecklm commented 4 years ago

AdaptingMonitor13's destructor is not called when the controller exits... Hopefully there is an event or something to handle this.

ecklm commented 4 years ago

Doing it in AdaptingMonitor.close()

127.0.0.1 - - [01/May/2020 10:43:24] "DELETE /qos/rules/all HTTP/1.1" 200 246 1.003129
200 - [
    {
        "command_result": {
            "details": "QoS rule is not exist.",
            "result": "failure"
        },
        "switch_id": "0000000000000001"
    }
]

Doing it right after they are created:

127.0.0.1 - - [01/May/2020 10:45:15] "DELETE /qos/rules/all HTTP/1.1" 200 248 0.007975
200 - [
    {
        "command_result": [
            {
                "details": " deleted. : QoS ID=1,2",
                "result": "success"
            }
        ],
        "switch_id": "0000000000000001"
    }
]

And it DOES remain there if I don't delete it.

ecklm commented 4 years ago

Hopefully now it's really doing what I expect it to.

ecklm commented 4 years ago

Try doing it in the RyuApp.stop() function. That is the one which stops the application. That might work better than RyuApp.close()