hnimminh / libresbc

An open source Session Border Controller 🌟 The SBC you dream about 🗽 LibreSBC will help you save thousands of dollars.
https://github.com/hnimminh/libresbc
MIT License
350 stars 79 forks source link

[BUG] unable update name outbound interconnection #146

Closed hnimminh closed 6 months ago

hnimminh commented 6 months ago
2024-01-04T21:01:45.169848+00:00 devsbc libresbc 1177020 INFO  space=httpapi, action=request, requestid=3c0af260-0666-4370-ae7e-94699a16d84e, request_body={'name': 'ANYPEER', 'desc': 'testing purpose route to anywhere ipv4', 'sipprofile': 'extnat', 'distribution': 'weight_based', 'rtpaddrs': ['0.0.0.0/0'], 'media_c
lass': 'GSTAR', 'capacity_class': 'UNLIMITED', 'translation_classes': [], 'manipulation_classes': [], 'privacy': ['none'], 'cid_type': 'none', 'nodes': ['_ALL_'], 'enable': True, 'gateways': [{'name': 'ANYGW', 'weight': 1}], 'engagements': ['record:somewhere:lpm:27']}                                                
2024-01-04T21:01:45.175230+00:00 devsbc libresbc 1177020 ERR  space=libreapi, action=update_outbound_interconnection, requestid=3c0af260-0666-4370-ae7e-94699a16d84e, exception=WRONGTYPE Operation against a key holding the wrong kind of value, traceback=Traceback (most recent call last):#012  File "/opt/libresbc/v0.
7.1.b/liberator/libreapi.py", line 2018, in update_outbound_interconnection#012    _endpoints = fieldjsonify(rdbconn.hget(f'routing:{engagement}', 'endpoints'))#012  File "/usr/local/lib/python3.9/dist-packages/redis/commands/core.py", line 4846, in hget#012    return self.execute_command("HGET", name, key)#012  Fi
le "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1258, in execute_command#012    return conn.retry.call_with_retry(#012  File "/usr/local/lib/python3.9/dist-packages/redis/retry.py", line 46, in call_with_retry#012    return do()#012  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1259, in <lambda>#012    lambda: self._send_command_parse_response(#012  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1235, in _send_command_parse_response#012    return self.parse_response(conn, command_name, **options)#012  File "/usr/local/lib/python3.9/dist-packages/redis/client.py", line 1275, in parse_response#012    response = connection.read_response()#012  File "/usr/local/lib/python3.9/dist-packages/redis/connection.py", line 865, in read_response#012    raise response#012redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
2024-01-04T21:01:45.176589+00:00 devsbc libresbc 1177020 INFO  space=httpapi, action=middleware, processtime=0.008, requestid=3c0af260-0666-4370-ae7e-94699a16d84e, clientip=85.253.103.46, request=put:/libreapi/interconnection/outbound/IMPLY, status_code=500, response_body=null
                # hash type
                if engagement.startswith('table'):
                    _endpoints = fieldjsonify(rdbconn.hget(f'routing:{engagement}', 'endpoints'))
                    if _endpoints:
                        endpoints = [name if endpoint == identifier else endpoint for endpoint in _endpoints]
                        pipe.hset(f'routing:{engagement}', 'endpoints', fieldredisify(endpoints))
                # string type
                if engagement.startswith('record'):
                    _endpoints = fieldjsonify(rdbconn.hget(f'routing:{engagement}', 'endpoints'))
                    _action = rdbconn.hget(f'routing:{engagement}', 'action')
                    if _endpoints and _action==_ROUTE:
                        endpoints = [name if endpoint == identifier else endpoint for endpoint in _endpoints]
                        pipe.hset(f'routing:{engagement}', 'endpoints', fieldredisify(endpoints))
hnimminh commented 6 months ago

fixed by https://github.com/hnimminh/libresbc/commit/fdb37a6b1665b3fd9a76d83c5abf9a81e95f1ee4