Repository navigation
[surfacers.probestatus] Don't panic when the dashboard window is under a minute - #1448
Merged
manugarg merged 1 commit intoSep 12, 2026
Merged
Conversation
…r a minute dashboardDurations() collects the base durations that fit within resolution_sec * timeseries_size, then reads result[len(result)-1] to decide whether to append maxDuration. baseDurations starts at one minute, so any product below 60s leaves result empty and the index panics. New() calls this before returning, so cloudprober dies at startup rather than surfacing a config error. Handle the empty case: when maxDuration is smaller than the smallest base duration it is the only sensible entry. Covered by two new cases in TestDashboardDurations, both of which panic without the guard.
erik-bessegato
marked this pull request as ready for review
August 31, 2026 21:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
dashboardDurations()builds the duration list for the status page dashboard:maxDurationisresolution_sec * timeseries_size, andbaseDurationsstartsat one minute. If that product is under 60s, nothing is appended and
result[len(result)-1]indexes an empty slice.New()calls it at probestatus.go:183 before returning, so this is a startuppanic rather than a bad page. With:
cloudprober exits immediately:
The defaults (60s x 4320) are far above the threshold, so this only shows up on
a deliberately short window -- a high-resolution, small-buffer setup.
Fix
Handle the empty case. When
maxDurationis below the smallest base durationit is the only sensible entry in the list, so the existing
appendis right;it just needs to not read the slice first.
Tests
Two cases added to
TestDashboardDurations(30s and 59s). Both panic againstcurrent main and pass with the change.
Verification
go test ./internal/surfacers/probestatus/...passes. Reverting dashboard.gowhile keeping the new test cases reproduces the panic in the test run, so the
cases genuinely cover the guard rather than just passing alongside it. Also
confirmed the config above now starts normally and the status page renders with
a 30s dashboard option.
Note
A zero
resolution_secortimeseries_sizemakesmaxDuration0, which nolonger panics with this change but produces a "0d" dashboard entry. That looked
like a separate question about validating the surfacer config in
New(), so Ileft it out of this PR -- happy to follow up if you'd like it rejected at
config time instead.