Skip to content

Commit

Permalink
Fix data-not-found unexpected exit
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshawkes committed Apr 5, 2024
1 parent 6ea682d commit 57ee4e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions polytope_server/garbage-collector/garbage_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def remove_dangling_data(self):
request = self.request_store.get_request(id=data.name)
if request is None:
logging.info("Deleting {} because it has no matching request.".format(data.name))
self.staging.delete(data.name)
try:
self.staging.delete(data.name)
except KeyError:
# TODO: why does this happen?
logging.info("Data {} not found in staging.".format(data.name))

def remove_by_size(self):
"""Cleans data according to size limits of the staging, removing older requests first."""
Expand Down Expand Up @@ -122,7 +126,10 @@ def remove_by_size(self):
# Delete objects in ascending last_modified order (oldest first)
for name, v in sorted(all_objects_by_age.items(), key=lambda x: x[1]["last_modified"]):
logging.info("Deleting {} because threshold reached and it is the oldest request.".format(name))
self.staging.delete(name)
try:
self.staging.delete(name)
except KeyError:
logging.info("Data {} not found in staging.".format(name))
self.request_store.remove_request(name)
total_size -= v["size"]
logging.info("Size of staging is {}/{}".format(total_size, self.threshold))
Expand Down

0 comments on commit 57ee4e4

Please sign in to comment.