praiskup / resalloc

Allocator and manager for (expensive) resources
GNU General Public License v2.0
7 stars 7 forks source link

Freshly added "on demand" pools break manager #128

Closed praiskup closed 11 months ago

praiskup commented 11 months ago

The resalloc-server manager fails with:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/resallocserver/main.py", line 140, in main
    Manager(sync).run()
  File "/usr/lib/python3.11/site-packages/resallocserver/manager.py", line 1089, in run
    self._loop()
  File "/usr/lib/python3.11/site-packages/resallocserver/manager.py", line 1073, in _loop
    pool.loop(self.sync.ticket)
  File "/usr/lib/python3.11/site-packages/resallocserver/manager.py", line 543, in loop
    self._clean_unknown_resources(event)
  File "/usr/lib/python3.11/site-packages/resallocserver/manager.py", line 691, in _clean_unknown_resources
    last_cleanup = dbinfo.cleaning_unknown_resources
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cleaning_unknown_resources'

That's because - until there's a first ticket triggering the spawner - there is no entry in database about the pool. hot-fix applied in production:

         with session_scope() as session:
             dbinfo = session.query(models.Pool).get(self.name)
+            if not dbinfo:
+                app.log.error("Unknown pool %s to cleanup", self.name)
+                return
             last_cleanup = dbinfo.cleaning_unknown_resources
             if last_cleanup is None:
                 last_cleanup = datetime.min