Skip to content

Always set BOT_COUNT metric in the run_bot task loop#5360

Merged
ViniciustCosta merged 1 commit into
masterfrom
dylanj/bot-metrics
Jul 16, 2026
Merged

Always set BOT_COUNT metric in the run_bot task loop#5360
ViniciustCosta merged 1 commit into
masterfrom
dylanj/bot-metrics

Conversation

@dylanjew

@dylanjew dylanjew commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

The update_task_enabled feature flag has been rolled out since Sept 2025 to all instances of clusterfuzz. However, the update task flow is used for non terraform managed bots.

The BOT_COUNT metric is only set in the update task flow and at bot tart up if is_untrusted_worker. However, windows bots trigger neither of those.

This PR only moves the BOT_COUNT metric outside of the update_task flow to ensure that update_task.track_revision() sets the BOT_COUNT metric for windows and other terraform managed bots.

It's safe to update the BOT_COUNT metric multiple times, because we're calling set on a Gauge metric based on the GCE instance.

I've added details to crbug.com/534369736

This will only affect mac, android and other bots not configured already in terraform with update_task_enabled = False

Testing
Dev metrics

@dylanjew
dylanjew requested a review from a team as a code owner July 13, 2026 20:16
@dylanjew
dylanjew requested a review from javanlacerda July 13, 2026 21:08
@dylanjew
dylanjew force-pushed the dylanj/bot-metrics branch from 5988e73 to 4dd5c13 Compare July 14, 2026 20:14
@dylanjew

Copy link
Copy Markdown
Collaborator Author

Updated PR to only move the metric and preserve the update task flow.

@dylanjew dylanjew changed the title Remove dead update_task_enabled flow in run_bot to fix bot metrics Always set BOT_COUNT metric in the run_bot task loop Jul 14, 2026
@dylanjew
dylanjew force-pushed the dylanj/bot-metrics branch from 4dd5c13 to 538dcc4 Compare July 15, 2026 17:30
@dylanjew
dylanjew requested a review from ViniciustCosta July 15, 2026 17:31
update_task.prepare_environment_for_new_task()
update_task.run_platform_init_scripts()

update_task.track_revision()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be inside the else right, because it would be called twice for the cases that the update task is enabled, as it is called by the update_task.run.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does track_revision get called in update_task.run? I only see it called in run_bot#main, and only for untrusted workers, which IIUC the mac bots are not.

But aside from that, I think it's ok to set a Gauge Metric multiple times on the same VM instance because the metric is only stored to the dict again and then emitted on flush every 10 minutes, which prevents the bot from counting itself multiple times.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! LGTM.

@dylanjew

Copy link
Copy Markdown
Collaborator Author

Pushed to dev and things look fine. There are metrics now. I think I had pushed this yesterday but dev was reset to master at some point, so that's why the metrics were there yesterday for a period

@dylanjew
dylanjew requested a review from javanlacerda July 15, 2026 19:26

@ViniciustCosta ViniciustCosta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ViniciustCosta
ViniciustCosta merged commit 5f7e9d7 into master Jul 16, 2026
15 checks passed
@ViniciustCosta
ViniciustCosta deleted the dylanj/bot-metrics branch July 16, 2026 13:02
jr2bg added a commit that referenced this pull request Jul 16, 2026
commit e4b33cd
Author: Arturo Barrera <jabgonzalez@google.com>
Date:   Thu Jul 16 13:39:52 2026 +0000

    Resolve comments on issue filing

    - issue_filer.py
    Get fuzzer from DataStore query, handles cases when no `primary_owner` is found, does not consider yet `external_contribution.

    - migrate_fuzzer_owners.py
    Removes the owner

commit b39db4e
Author: Arturo Barrera <jabgonzalez@google.com>
Date:   Mon Jun 15 18:47:45 2026 +0000

    Migrate from monorail to buganizer.

commit eae2447
Author: Arturo Barrera <jabgonzalez@google.com>
Date:   Fri Jun 12 20:07:11 2026 +0000

    Add license. Modify locations.

commit e0113e7
Author: Arturo Barrera <jabgonzalez@google.com>
Date:   Fri May 22 17:30:28 2026 +0000

    Set fuzzer author as reporter for bugs from external fuzzers

commit 5f7e9d7
Author: Dylan Jew <dylanjew@users.noreply.github.com>
Date:   Thu Jul 16 09:02:36 2026 -0400

    Always set BOT_COUNT metric in the run_bot task loop (#5360)

    The update_task_enabled feature flag has been rolled out since Sept 2025
    to all instances of clusterfuzz. However, the update task flow is used
    for non terraform managed bots.

    The BOT_COUNT metric is only set in the update task flow and at bot tart
    up if `is_untrusted_worker`. However, windows bots trigger neither of
    those.

    This PR only moves the BOT_COUNT metric outside of the update_task flow
    to ensure that `update_task.track_revision()` sets the BOT_COUNT metric
    for windows and other terraform managed bots.

    It's safe to update the BOT_COUNT metric multiple times, because we're
    calling `set` on a `Gauge` metric based on the GCE instance.

    I've added details to crbug.com/534369736

    This will only affect mac, android and other bots not configured already
    in terraform with `update_task_enabled = False`

    Testing
    Dev
    [metrics](https://pantheon.corp.google.com/monitoring/metrics-explorer;duration=P2D?pageState=%7B%22xyChart%22:%7B%22dataSets%22:%5B%7B%22timeSeriesQuery%22:%7B%22timeSeriesFilter%22:%7B%22filter%22:%22metric.type%3D%5C%22custom.googleapis.com%2Fbot_count%5C%22%20resource.type%3D%5C%22gce_instance%5C%22%22,%22aggregation%22:%7B%22perSeriesAligner%22:%22ALIGN_MEAN%22,%22crossSeriesReducer%22:%22REDUCE_SUM%22,%22groupByFields%22:%5B%22metric.label.%5C%22os_type%5C%22%22%5D,%22alignmentPeriod%22:%2260s%22%7D%7D%7D,%22plotType%22:%22LINE%22,%22targetAxis%22:%22Y1%22,%22minAlignmentPeriod%22:%2260s%22%7D%5D,%22chartOptions%22:%7B%22mode%22:%22COLOR%22,%22displayHorizontal%22:false%7D,%22thresholds%22:%5B%5D,%22yAxis%22:%7B%22scale%22:%22LINEAR%22%7D%7D%7D&project=clusterfuzz-development)

commit 900904e
Author: Giovanni Ortuño <ortuno@google.com>
Date:   Thu Jul 16 08:44:19 2026 -0400

     symbolizer: Stop using llvm-symbolizer if it crashes (#5361)

    Changes LLVMSymbolizer.symbolize() to return early if it previously
    raised an error. This avoids trying to use the crashed symbolizer for
    every new frame which is currently causing a lot of error logs.

    Also changes the error message to include the last successfully
    symbolized frame.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants