From dcb7060f263260d2d881920de7d1e54b46af6224 Mon Sep 17 00:00:00 2001 From: Benjamin Ludwig Date: Tue, 9 Aug 2022 10:13:47 +0200 Subject: [PATCH] [status_manager] Fix listener statistics update Octavia offers a dedicated ListenerStatistics class now, which is also the model_class of self.listener_stats_repo Also: Remove docstring for v1, v1 is not used. --- .../health_drivers/update_db.py | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/octavia_f5/controller/statusmanager/legacy_healthmanager/health_drivers/update_db.py b/octavia_f5/controller/statusmanager/legacy_healthmanager/health_drivers/update_db.py index 3ddc2947..9b2597a9 100644 --- a/octavia_f5/controller/statusmanager/legacy_healthmanager/health_drivers/update_db.py +++ b/octavia_f5/controller/statusmanager/legacy_healthmanager/health_drivers/update_db.py @@ -484,38 +484,12 @@ def update_stats(self, health_message, srcaddr): '%s', health_message['id'], srcaddr) def _update_stats(self, health_message, srcaddr): - """This function is to update the db with listener stats + """Update listener statistics :param health_message: The health message containing the listener stats :type map: string :returns: null - Example V1 message:: - - health = { - "id": self.FAKE_UUID_1, - "listeners": { - "listener-id-1": { - "status": constants.OPEN, - "stats": { - "ereq":0, - "conns": 0, - "totconns": 0, - "rx": 0, - "tx": 0, - }, - "pools": { - "pool-id-1": { - "status": constants.UP, - "members": {"member-id-1": constants.ONLINE} - } - } - } - } - } - - Example V2 message:: - {"id": "", "seq": 67, "listeners": { @@ -553,8 +527,11 @@ def _update_stats(self, health_message, srcaddr): 'active_connections': stats['conns'], 'total_connections': stats['totconns'], 'request_errors': stats['ereq']} - LOG.debug("Updating listener stats in db and sending event.") + stats_obj = self.listener_stats_repo.model_class( + listener_id=listener_id, + amphora_id=amphora_id, + **stats + ) LOG.debug("Listener %s / Amphora %s stats: %s", listener_id, amphora_id, stats) - self.listener_stats_repo.replace( - session, listener_id, amphora_id, **stats) + self.listener_stats_repo.replace(session, stats_obj)