Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging remainder PRs into chrome branch #4546

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/clusterfuzz/_internal/build_management/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,17 @@ def _emit_build_age_metric(gcs_path):
logs.error(f'Failed to emit build age metric for {gcs_path}: {e}')


def _emit_build_revision_metric(revision):
"""Emits a gauge metric to track the build revision."""
monitoring_metrics.JOB_BUILD_REVISION.set(
revision,
labels={
'job': os.getenv('JOB_NAME'),
'platform': environment.platform(),
'task': os.getenv('TASK_NAME'),
})


def _get_build_url(bucket_path: Optional[str], revision: int,
job_type: Optional[str]):
"""Returns the GCS url for a build, given a bucket path and revision"""
Expand Down Expand Up @@ -1290,6 +1301,7 @@ def setup_regular_build(revision,

if revision == latest_revision:
_emit_build_age_metric(build_url)
_emit_build_revision_metric(revision)

# build_url points to a GCP bucket, and we're only converting it to its HTTP
# endpoint so that we can use remote unzipping.
Expand Down
4 changes: 4 additions & 0 deletions src/clusterfuzz/_internal/cron/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ def group_testcases():
try:
issue_tracker = issue_tracker_utils.get_issue_tracker_for_testcase(
testcase)
if issue_tracker:
logs.info(
f'Running grouping with issue tracker {issue_tracker.project}, '
f' for testcase {testcase_id}')
except ValueError:
logs.error('Couldn\'t get issue tracker for issue.')
del testcase_map[testcase_id]
Expand Down
11 changes: 10 additions & 1 deletion src/clusterfuzz/_internal/cron/triage.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ def main():
testcase = data_handler.get_testcase_by_id(testcase_id)
except errors.InvalidTestcaseError:
# Already deleted.
logs.info(
f'Skipping testcase {testcase_id}, since it was already deleted.')
continue

critical_tasks_completed = data_handler.critical_tasks_completed(testcase)
Expand All @@ -410,6 +412,7 @@ def main():
_emit_untriaged_testcase_age_metric(testcase)
_increment_untriaged_testcase_count(testcase.job_type,
PENDING_PROGRESSION)
logs.info(f'Skipping testcase {testcase_id}, progression pending')
continue

# If the testcase has a bug filed already, no triage is needed.
Expand Down Expand Up @@ -466,8 +469,14 @@ def main():

# If this project does not have an associated issue tracker, we cannot
# file this crash anywhere.
issue_tracker = issue_tracker_utils.get_issue_tracker_for_testcase(testcase)
try:
issue_tracker = issue_tracker_utils.get_issue_tracker_for_testcase(
testcase)
except ValueError:
issue_tracker = None
if not issue_tracker:
logs.info(f'No issue tracker detected for testcase {testcase_id}, '
'publishing message.')
issue_filer.notify_issue_update(testcase, 'new')
continue

Expand Down
12 changes: 10 additions & 2 deletions src/clusterfuzz/_internal/issue_management/issue_tracker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from clusterfuzz._internal.issue_management import issue_tracker_policy
from clusterfuzz._internal.issue_management import jira
from clusterfuzz._internal.issue_management import monorail
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment

_ISSUE_TRACKER_CACHE_CAPACITY = 8
Expand All @@ -43,7 +44,10 @@ def _get_issue_tracker_project_name(testcase=None):
"""Return issue tracker project name given a testcase or default."""
from clusterfuzz._internal.datastore import data_handler
job_type = testcase.job_type if testcase else None
return data_handler.get_issue_tracker_name(job_type)
issue_tracker_name = data_handler.get_issue_tracker_name(job_type)
logs.info(
f'For testcase {testcase.key}, using issue tracker {issue_tracker_name}')
return issue_tracker_name


def request_or_task_cache(func):
Expand All @@ -66,8 +70,12 @@ def get_issue_tracker(project_name=None):
issue_project_config = issue_tracker_config.get(project_name)
if not issue_project_config:
raise ValueError('Issue tracker for {} does not exist'.format(project_name))
logs.info(f'Issue tracker = {project_name}, issue tracker config = '
f'{issue_project_config}')

constructor = _ISSUE_TRACKER_CONSTRUCTORS.get(issue_project_config['type'])
issue_tracker_type = issue_project_config['type']
constructor = _ISSUE_TRACKER_CONSTRUCTORS.get(issue_tracker_type)
logs.info(f'Using the issue tracker constructor for {issue_tracker_type}')
if not constructor:
raise ValueError('Invalid issue tracker type: ' +
issue_project_config['type'])
Expand Down
11 changes: 11 additions & 0 deletions src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
],
)

JOB_BUILD_REVISION = monitor.GaugeMetric(
'job/build_revision',
description=('Gauge for revision of trunk build '
'(grouped by job/platform/task).'),
field_spec=[
monitor.StringField('job'),
monitor.StringField('platform'),
monitor.StringField('task'),
],
)

JOB_BUILD_RETRIEVAL_TIME = monitor.CumulativeDistributionMetric(
'task/build_retrieval_time',
bucketer=monitor.GeometricBucketer(),
Expand Down
Loading