Merge pull request #2385 from coreos-inc/remove-image-count
Remove images count (which is horribly slow in InnoDB) and add a max gauge
This commit is contained in:
commit
a5fd52f34b
2 changed files with 4 additions and 5 deletions
|
@ -7,7 +7,6 @@ from data.database import UseThenDisconnect
|
||||||
from data import model
|
from data import model
|
||||||
from data.model.image import total_image_count
|
from data.model.image import total_image_count
|
||||||
from util.locking import GlobalLock, LockNotAcquiredException
|
from util.locking import GlobalLock, LockNotAcquiredException
|
||||||
from workers.securityworker import images_gauge
|
|
||||||
from workers.worker import Worker
|
from workers.worker import Worker
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -43,8 +42,6 @@ class GlobalPrometheusStatsWorker(Worker):
|
||||||
metric_queue.org_count.Set(model.organization.get_active_org_count())
|
metric_queue.org_count.Set(model.organization.get_active_org_count())
|
||||||
metric_queue.robot_count.Set(model.user.get_robot_count())
|
metric_queue.robot_count.Set(model.user.get_robot_count())
|
||||||
|
|
||||||
images_gauge.Set(total_image_count())
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.config.fileConfig('conf/logging_debug.conf', disable_existing_loggers=False)
|
logging.config.fileConfig('conf/logging_debug.conf', disable_existing_loggers=False)
|
||||||
|
|
|
@ -21,8 +21,8 @@ INDEXING_INTERVAL = 30
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
unscanned_images_gauge = prometheus.create_gauge('unscanned_images',
|
unscanned_images_gauge = prometheus.create_gauge('unscanned_images',
|
||||||
'Number of images that clair needs to scan.')
|
'Number of images that clair needs to scan.')
|
||||||
images_gauge = prometheus.create_gauge('all_images', 'Total number of images that clair can scan.')
|
max_unscanned_images_gauge = prometheus.create_gauge('max_unscanned_image_id',
|
||||||
|
'Max ID of the unscanned images.')
|
||||||
|
|
||||||
class SecurityWorker(Worker):
|
class SecurityWorker(Worker):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -49,6 +49,8 @@ class SecurityWorker(Worker):
|
||||||
if max_id is None:
|
if max_id is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
max_unscanned_images_gauge.Set(max_id)
|
||||||
|
|
||||||
with UseThenDisconnect(app.config):
|
with UseThenDisconnect(app.config):
|
||||||
to_scan_generator = yield_random_entries(
|
to_scan_generator = yield_random_entries(
|
||||||
batch_query,
|
batch_query,
|
||||||
|
|
Reference in a new issue