yapf format
This commit is contained in:
parent
76c9339453
commit
138881dab8
4 changed files with 9 additions and 2 deletions
|
@ -3,6 +3,7 @@ from data.database import UseThenDisconnect
|
|||
from workers.gc.models_pre_oci import pre_oci_model as model
|
||||
from workers.worker import Worker
|
||||
|
||||
|
||||
class GarbageCollectionWorker(Worker):
|
||||
def __init__(self):
|
||||
super(GarbageCollectionWorker, self).__init__()
|
||||
|
@ -14,6 +15,7 @@ class GarbageCollectionWorker(Worker):
|
|||
with UseThenDisconnect(app.config):
|
||||
model.perform_garbage_collection()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
worker = GarbageCollectionWorker()
|
||||
worker.start()
|
||||
|
|
|
@ -2,11 +2,13 @@ from abc import ABCMeta, abstractmethod
|
|||
|
||||
from six import add_metaclass
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class GCWorkerDataInterface(object):
|
||||
"""
|
||||
Interface that represents all data store interactions required by the GC worker.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def perform_garbage_collection(self):
|
||||
""" Performs garbage collection on a single repository, if any can be found with garbage. """
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import logging
|
||||
|
||||
from data.model.repository import (find_repository_with_garbage, garbage_collect_repo,
|
||||
get_random_gc_policy)
|
||||
from data.model.repository import (
|
||||
find_repository_with_garbage, garbage_collect_repo, get_random_gc_policy)
|
||||
|
||||
from workers.gc.models_interface import GCWorkerDataInterface
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PreOCIModel(GCWorkerDataInterface):
|
||||
def perform_garbage_collection(self):
|
||||
repository = find_repository_with_garbage(get_random_gc_policy())
|
||||
|
@ -18,4 +19,5 @@ class PreOCIModel(GCWorkerDataInterface):
|
|||
garbage_collect_repo(repository)
|
||||
logger.debug('Finished GC of repository #%s (%s)', repository.id, repository.name)
|
||||
|
||||
|
||||
pre_oci_model = PreOCIModel()
|
||||
|
|
|
@ -2,6 +2,7 @@ from workers.gc.gcworker import GarbageCollectionWorker
|
|||
|
||||
from test.fixtures import *
|
||||
|
||||
|
||||
def test_gc(initialized_db):
|
||||
worker = GarbageCollectionWorker()
|
||||
worker._garbage_collection_repos()
|
||||
|
|
Reference in a new issue