]> git.ipfire.org Git - ipfire.org.git/commitdiff
mirrors: Add faster timeouts to mirror checks
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 10:18:16 +0000 (10:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 10:18:16 +0000 (10:18 +0000)
The checker used to freeze here sometimes as the default timeouts where
pretty much to infinity and beyond.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/mirrors.py

index b1d8a6a59ef52b240310cc117fbc3e0ebabbcf6a..26958553f016e1d914e837160fe5d70c268615c9 100644 (file)
@@ -238,8 +238,18 @@ class Mirror(Object):
 
        async def check_timestamp(self):
                try:
-                       response = await self.backend.http_client.fetch(self.url + ".timestamp",
-                               headers={ "Pragma" : "no-cache" })
+                       response = await self.backend.http_client.fetch(
+                               self.url + ".timestamp",
+                               headers = {
+                                       "Pragma" : "no-cache",
+                               },
+
+                               # We are really not very patient with this, because if the
+                               # mirror cannot give us the timestamp swiftly, it is probably
+                               # very overloaded and won't respond quickly to any file requests.
+                               connect_timeout = 10,
+                               request_timeout = 10,
+                       )
                except tornado.httpclient.HTTPError as e:
                        logging.warning("Error getting timestamp from %s: %s" % (self.hostname, e))
                        self.set_state("DOWN")
@@ -288,8 +298,16 @@ class Mirror(Object):
                        return
 
                try:
-                       response = await self.backend.http_client.fetch(self.url + ".filelist",
-                               headers={ "Pragma" : "no-cache" })
+                       response = await self.backend.http_client.fetch(
+                               self.url + ".filelist",
+                               headers = {
+                                       "Pragma" : "no-cache",
+                                },
+
+                               # Don't wait very long for this
+                               connect_timeout = 10,
+                               request_timeout = 10,
+                       )
                except tornado.httpclient.HTTPError as e:
                        logging.warning("Error getting filelist from %s: %s" % (self.hostname, e))
                        self.set_state("DOWN")