From 8b02e21e6e3182b914153b63ec6ecc81dac32d70 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 36a8faf..8306c7b 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.error("Can't perform cleanup in the configured " + "pool %s: no such pool in database.", + self.name) + return last_cleanup = dbinfo.cleaning_unknown_resources if last_cleanup is None: last_cleanup = datetime.min