Merge pull request #1253 from Quentin-M/clair2

Adapt securityworker, secscan API and Quay UI for Clair 1.0
This commit is contained in:
Quentin Machu 2016-02-19 18:21:25 -05:00
commit 0183c519f7
7 changed files with 283 additions and 291 deletions

View file

@ -14,9 +14,9 @@ class NoAvailableKeysError(ValueError):
class CompletedKeys(object):
def __init__(self, max_index):
def __init__(self, min_index, max_index):
self._max_index = max_index
self._min_index = 0
self._min_index = min_index
self._slabs = RBTree()
def _get_previous_or_none(self, index):
@ -118,7 +118,7 @@ class CompletedKeys(object):
return random.randint(hole_start, rand_max_bound)
def yield_random_entries(batch_query, primary_key_field, batch_size, max_id):
def yield_random_entries(batch_query, primary_key_field, batch_size, max_id, min_id=0):
""" This method will yield items from random blocks in the database. We will track metadata
about which keys are available for work, and we will complete the backfill when there is no
more work to be done. The method yields tupes of (candidate, Event), and if the work was
@ -126,8 +126,9 @@ def yield_random_entries(batch_query, primary_key_field, batch_size, max_id):
an "id" field which can be inspected.
"""
min_id = max(min_id, 0)
max_id = max(max_id, 1)
allocator = CompletedKeys(max_id + 1)
allocator = CompletedKeys(min_id, max_id + 1)
try:
while True: