From cb8b39030f974f356bc3b3a39a83fea12d15fd72 Mon Sep 17 00:00:00 2001 From: Vitor Guidi Date: Mon, 16 Dec 2024 10:39:06 -0300 Subject: [PATCH] Fix lint --- src/clusterfuzz/_internal/common/testcase_utils.py | 10 +++++----- src/clusterfuzz/_internal/cron/triage.py | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/clusterfuzz/_internal/common/testcase_utils.py b/src/clusterfuzz/_internal/common/testcase_utils.py index df12a69558..3c0f6512c8 100644 --- a/src/clusterfuzz/_internal/common/testcase_utils.py +++ b/src/clusterfuzz/_internal/common/testcase_utils.py @@ -47,9 +47,6 @@ def emit_testcase_triage_duration_metric(testcase_id: int, step: str): 'analyze_launched', 'analyze_completed', 'minimize_completed', 'regression_completed', 'impact_completed', 'issue_updated' ] - elapsed_time_since_upload = datetime.datetime.utcnow() - elapsed_time_since_upload -= testcase_upload_metadata.timestamp - elapsed_time_since_upload = elapsed_time_since_upload.total_seconds() / 3600 testcase = data_handler.get_testcase_by_id(testcase_id) @@ -74,12 +71,15 @@ def emit_testcase_triage_duration_metric(testcase_id: int, step: str): logs.warning(f'No timestamp associated to testcase {testcase_id},' ' failed to emit TESTCASE_UPLOAD_TRIAGE_DURATION metric.') return + + testcase_age_in_hours = testcase.get_age_in_seconds() / 3600 + logs.info('Emiting TESTCASE_UPLOAD_TRIAGE_DURATION metric for testcase ' - f'{testcase_id} (age = {elapsed_time_since_upload}) ' + f'{testcase_id} (age = {testcase_age_in_hours} hours.) ' 'in step {step}.') monitoring_metrics.TESTCASE_UPLOAD_TRIAGE_DURATION.add( - testcase.get_age_in_seconds(), + testcase_age_in_hours, labels={ 'job': testcase.job_type, 'step': step, diff --git a/src/clusterfuzz/_internal/cron/triage.py b/src/clusterfuzz/_internal/cron/triage.py index 8b36c42232..1f3b375922 100644 --- a/src/clusterfuzz/_internal/cron/triage.py +++ b/src/clusterfuzz/_internal/cron/triage.py @@ -433,7 +433,6 @@ def main(): # finished. if not critical_tasks_completed: _emit_untriaged_testcase_age_metric(testcase) - untriaged_testcases += 1 _set_testcase_stuck_state(testcase, True) _increment_untriaged_testcase_count(testcase.job_type, PENDING_CRITICAL_TASKS) @@ -454,7 +453,6 @@ def main(): if not testcase.group_id and not dates.time_has_expired( testcase.timestamp, hours=data_types.MIN_ELAPSED_TIME_SINCE_REPORT): _emit_untriaged_testcase_age_metric(testcase) - untriaged_testcases += 1 _set_testcase_stuck_state(testcase, True) _increment_untriaged_testcase_count(testcase.job_type, PENDING_GROUPING) logs.info(f'Skipping testcase {testcase_id}, pending grouping.') @@ -463,7 +461,6 @@ def main(): if not testcase.get_metadata('ran_grouper'): # Testcase should be considered by the grouper first before filing. _emit_untriaged_testcase_age_metric(testcase) - untriaged_testcases += 1 _set_testcase_stuck_state(testcase, True) _increment_untriaged_testcase_count(testcase.job_type, PENDING_GROUPING) logs.info(f'Skipping testcase {testcase_id}, pending grouping.') @@ -495,7 +492,6 @@ def main(): # A testcase is untriaged, until immediately before a bug is opened _emit_untriaged_testcase_age_metric(testcase) - untriaged_testcases += 1 _set_testcase_stuck_state(testcase, False) _increment_untriaged_testcase_count(testcase.job_type, PENDING_FILING)