Skip to content
Snippets Groups Projects
Verified Commit fe32b72f authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Have LibreNMS client perform multiple retires when a connection times out

parent 35d11e8e
Branches
Tags
No related merge requests found
Pipeline #88380 failed
......@@ -7,6 +7,7 @@ from typing import Any, Literal
import requests
from requests import HTTPError, Response
from requests.adapters import HTTPAdapter
from gso.settings import load_oss_params
from gso.utils.helpers import SNMPVersion
......@@ -26,6 +27,7 @@ class LibreNMSClient:
self.snmp_config = config.SNMP
self.session = requests.Session()
self.session.mount("https://", HTTPAdapter(max_retries=5))
self.session.headers.update({
"User-Agent": f"geant-service-orchestrator/{metadata.version("geant-service-orchestrator")}",
"Accept": "application/json",
......@@ -38,7 +40,7 @@ class LibreNMSClient:
) -> Response:
url = self.base_url + endpoint
logger.debug("LibreNMS - Sending request", extra={"method": method, "endpoint": url, "form_data": data})
result = self.session.request(method, url, json=data)
result = self.session.request(method, url, json=data, timeout=(0.5, 75))
logger.debug("LibreNMS - Received response", extra=result.__dict__)
return result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment