]> git.ipfire.org Git - pbs.git/commitdiff
builders: Don't send start/shutdown signal again
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 May 2023 14:20:23 +0000 (14:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 May 2023 14:20:23 +0000 (14:20 +0000)
This saves us some API calls and log messages.

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

index 74d5e9578ea8ef4fc5c55a3b9f4d3217452e03d5..f709e811dbff9c1996e7c366d7b234925685c16c 100644 (file)
@@ -562,7 +562,7 @@ class Builder(base.DataObject):
 
                return state in ("pending", "running")
 
-       async def is_shutdown(self):
+       async def is_shut_down(self):
                """
                        Returns True if this builder is shut down
                """
@@ -589,6 +589,10 @@ class Builder(base.DataObject):
                """
                        Starts the instance on AWS
                """
+               # Do nothing if the builder is already running
+               if await self.is_running():
+                       return
+
                await asyncio.to_thread(self._start, wait=wait)
 
        def _start(self, wait):
@@ -645,6 +649,10 @@ class Builder(base.DataObject):
                """
                        Stops this instance on AWS
                """
+               # Do nothing if the builder is already shut down
+               if await self.is_shutting_down() or await self.is_shut_down():
+                       return
+
                await asyncio.to_thread(self._stop, wait=wait)
 
        def _stop(self, wait):