Raise an APIRequestFailure exception when security scanner is unavailable
Put worker to sleep for the duration of the default indexing interval when an APIRequestFailure occurs, when the API request fails due to a connection error, timeout, or other ambiguous errors, from analyze_layer or get_layer_data .
This commit is contained in:
parent
13439e0ca7
commit
203c0b76e0
3 changed files with 8 additions and 5 deletions
|
@ -10,7 +10,7 @@ from workers.worker import Worker
|
|||
from data.database import UseThenDisconnect
|
||||
from data.model.image import (get_images_eligible_for_scan, get_image_pk_field,
|
||||
get_max_id_for_sec_scan, get_min_id_for_sec_scan)
|
||||
from util.secscan.api import SecurityConfigValidator
|
||||
from util.secscan.api import SecurityConfigValidator, APIRequestFailure
|
||||
from util.secscan.analyzer import LayerAnalyzer, PreemptedException
|
||||
from util.migrate.allocator import yield_random_entries
|
||||
from endpoints.v2 import v2_bp
|
||||
|
@ -73,6 +73,8 @@ class SecurityWorker(Worker):
|
|||
except PreemptedException:
|
||||
logger.info('Another worker pre-empted us for layer: %s', candidate.id)
|
||||
abt.set()
|
||||
except APIRequestFailure:
|
||||
time.sleep(DEFAULT_INDEXING_INTERVAL)
|
||||
|
||||
unscanned_images_gauge.Set(num_remaining)
|
||||
|
||||
|
|
Reference in a new issue