From de133c4c78cb513444235ee9d8110685a33043f7 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sun, 5 Nov 2023 08:02:19 +0100 Subject: [PATCH] manager: fix "unknown resources cleanup" traceback When a new on-demand pool is configured in pools.yaml, the cleanup logic is typically executed before a new resource is started there, and thus also before the database entry is created. Fixes: #128 Fixes: #115 --- resallocserver/manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resallocserver/manager.py b/resallocserver/manager.py index 2e5752a..f09b199 100644 --- a/resallocserver/manager.py +++ b/resallocserver/manager.py @@ -688,6 +688,11 @@ def _clean_unknown_resources(self, event): with session_scope() as session: dbinfo = session.query(models.Pool).get(self.name) + if not dbinfo: + app.log.warning( + "Can not perform cleanup in the configured " + "pool %s: no such pool in SQL database.", self.name) + return last_cleanup = dbinfo.cleaning_unknown_resources if last_cleanup is None: last_cleanup = datetime.min