Commit 58b1443f authored by Morten Brekkevold's avatar Morten Brekkevold
Browse files

Ensure Kind requests will timeout

Because:
- It seems the request will hang indefinitely if a firewall rule is
  blocking access to Kind.
parent 83331041
......@@ -21,6 +21,7 @@ from slack_log_handler import SlackLogHandler
from kindnavsync.errors import retry_on_timeout
from kindnavsync.navapi import NAVAPI, ObjectNotFound, ClientError
KIND_REQUEST_TIMEOUT = 30.0 # seconds
KIND_SERVICE_URL = "https://kind.uninett.no/autoregister/utstyr_eksport.json"
KIND_UTSTYR_URL = "https://kind.uninett.no/utstyr/edit_utstyr.html?id={id}"
NAV_BOX_URL = "https://uninav.uninett.no/ipdevinfo/{sysname}/"
......@@ -197,7 +198,9 @@ def get_kind_data(services: list = None):
"""Fetches device data from Kind, using an optional service filter"""
LOG.debug("Henter data fra %s (tjenestefilter: %r)", KIND_SERVICE_URL, services)
params = {"tjenester": services} if services else {}
response = requests.get(KIND_SERVICE_URL, params=params)
response = requests.get(
KIND_SERVICE_URL, params=params, timeout=KIND_REQUEST_TIMEOUT
)
LOG.debug("Fikk respons fra %s", response.url)
return response.json()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment