Ignore undeploying builds when counting deployed

Otherwise the undeployer evicts too many builds
as it loops until the first builds are actually deleted.
This commit is contained in:
Stéphane Bidoul 2021-11-30 21:46:25 +01:00
parent b873d09d22
commit b21a7c92f8
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
2 changed files with 8 additions and 1 deletions

View file

@ -85,7 +85,7 @@ class Controller:
@property @property
def deployed(self) -> int: def deployed(self) -> int:
return self.db.count_all() return self.db.count_deployed()
@property @property
def max_deployed(self) -> int: def max_deployed(self) -> int:

View file

@ -170,6 +170,13 @@ class BuildsDb:
count = self._con.execute("SELECT COUNT(name) FROM builds").fetchone()[0] count = self._con.execute("SELECT COUNT(name) FROM builds").fetchone()[0]
return cast(int, count) return cast(int, count)
def count_deployed(self) -> int:
count = self._con.execute(
"SELECT COUNT(name) FROM builds WHERE status!=?",
(BuildStatus.undeploying,),
).fetchone()[0]
return cast(int, count)
def to_cleanup(self) -> list[Build]: def to_cleanup(self) -> list[Build]:
rows = self._con.execute( rows = self._con.execute(
"SELECT * FROM builds WHERE status=? ORDER BY created", "SELECT * FROM builds WHERE status=? ORDER BY created",