Skip to content

Conversation

@ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Dec 2, 2025

Description

Fixes the exp scaletest prebuilds command where the prometheus server was being shut down before waiting for metrics to be scraped.

The issue was the defer order - since defers execute in LIFO (last-in, first-out) order:

Before (broken):

  1. Register tracing defer (includes wait for prometheus scrape)
  2. Register prometheus server defer

Execution order: prometheus closes first, then wait happens (server already gone!)

After (fixed):

  1. Register prometheus server defer
  2. Register tracing defer (includes wait for prometheus scrape)

Execution order: wait happens first (server still up), then prometheus closes.

This matches the pattern used in other scaletest commands.

Impact

The coderd_scaletest_prebuild_deletion_jobs_completed metric (and potentially others) was always showing 0 because the server shut down before Prometheus could scrape the final values.

This PR was generated by mux and reviewed by a human.

The defer order in the prebuilds scaletest command was incorrect. The
prometheus server was being closed before the code waited for metrics
to be scraped, because defers execute in LIFO order.

Reorder the defers to match other scaletest commands: register the
prometheus server defer first, then the tracing/wait defer second.
This ensures the wait happens while the server is still running.
@ethanndickson ethanndickson changed the title fix(scaletest): fix prometheus server closing before metrics scraped fix(cli): close prebuild runner prometheus server last Dec 2, 2025
Same issue as prebuilds - the prometheus server defer was registered
after the tracing/wait defer, causing the server to shut down before
metrics could be scraped.
@ethanndickson ethanndickson enabled auto-merge (squash) December 2, 2025 12:05
@ethanndickson ethanndickson merged commit bf40d67 into main Dec 2, 2025
36 checks passed
@ethanndickson ethanndickson deleted the fix-scaletest-prebuild-metrics branch December 2, 2025 12:10
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants