find work based on tag IDs rather than image IDs

This commit is contained in:
Jimmy Zelinskie 2017-03-06 16:11:17 -05:00
parent 2cead05f53
commit 40636d4103
2 changed files with 26 additions and 7 deletions

View file

@ -6,8 +6,8 @@ import features
from app import app, secscan_api, prometheus
from workers.worker import Worker
from data.database import UseThenDisconnect
from data.model.image import get_max_id_for_sec_scan, get_min_id_for_sec_scan, get_image_id
from data.model.tag import get_tags_images_eligible_for_scan
from data.model.tag import (get_tags_images_eligible_for_scan, get_tag_pk_field,
get_max_id_for_sec_scan, get_min_id_for_sec_scan)
from util.secscan.api import SecurityConfigValidator
from util.secscan.analyzer import LayerAnalyzer, PreemptedException
from util.migrate.allocator import yield_random_entries
@ -56,14 +56,14 @@ class SecurityWorker(Worker):
with UseThenDisconnect(app.config):
to_scan_generator = yield_random_entries(
batch_query,
get_image_id(),
get_tag_pk_field(),
BATCH_SIZE,
max_id,
self._min_id,
)
for candidate, abt, num_remaining in to_scan_generator:
try:
self._analyzer.analyze_recursively(candidate)
self._analyzer.analyze_recursively(candidate.image)
except PreemptedException:
logger.info('Another worker pre-empted us for layer: %s', candidate.id)
abt.set()