]> git.ipfire.org Git - pbs.git/commitdiff
builders: Raise BuilderNotOnlineError if the connection does not work
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Mar 2025 10:46:01 +0000 (10:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Mar 2025 10:46:01 +0000 (10:46 +0000)
In case we have a connection, but it has gone away, we will just pretend
that the builder is offline.

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

index 54aedb229628ef1aee0f5a0f05714b87623a63b1..36781aa7883aeb84834b328b1f9f8bcd105c3204 100644 (file)
@@ -924,7 +924,12 @@ class Builder(database.Base, database.BackendMixin, database.SoftDeleteMixin):
                        self, json.dumps(message, indent=4, sort_keys=True))
 
                # Write the message to the control connection
-               return self.connection.write_message(message)
+               try:
+                       return self.connection.write_message(message)
+
+               # If the connection broke, we raise BuilderNotOnlineError
+               except tornado.websocket.WebSocketClosedError as e:
+                       raise BuilderNotOnlineError(self) from e
 
        # Uploads