parent
0b50928900
commit
aeddc6af06
1 changed files with 14 additions and 4 deletions
|
@ -2,7 +2,7 @@ import logging
|
|||
import random
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
from peewee import JOIN_LEFT_OUTER, fn, SQL
|
||||
from peewee import JOIN_LEFT_OUTER, fn, SQL, IntegrityError
|
||||
from cachetools import ttl_cache
|
||||
|
||||
from data.model import (DataModelException, tag, db_transaction, storage, permission,
|
||||
|
@ -175,10 +175,20 @@ def garbage_collect_repo(repo):
|
|||
|
||||
# Delete any derived images and the images themselves.
|
||||
if has_derived:
|
||||
DerivedStorageForImage.delete().where(
|
||||
DerivedStorageForImage.source_image << to_remove).execute()
|
||||
try:
|
||||
(DerivedStorageForImage
|
||||
.delete()
|
||||
.where(DerivedStorageForImage.source_image << to_remove)
|
||||
.execute())
|
||||
except IntegrityError:
|
||||
logger.info('Could not GC derived images %s; will try again soon', to_remove)
|
||||
return
|
||||
|
||||
Image.delete().where(Image.id << to_remove).execute()
|
||||
try:
|
||||
Image.delete().where(Image.id << to_remove).execute()
|
||||
except IntegrityError:
|
||||
logger.info('Could not GC images %s; will try again soon', to_remove)
|
||||
return
|
||||
|
||||
if len(to_remove) > 0:
|
||||
logger.info('Garbage collecting storage for images: %s', to_remove)
|
||||
|
|
Reference in a new issue