fix(monitor): clamp Span.Progress Count to Total#1243
Open
shaun0927 wants to merge 1 commit intogorse-io:masterfrom
Open
fix(monitor): clamp Span.Progress Count to Total#1243shaun0927 wants to merge 1 commit intogorse-io:masterfrom
shaun0927 wants to merge 1 commit intogorse-io:masterfrom
Conversation
The zero-total child fallback introduced in gorse-io#1208 lets parentCount exceed parentTotal when the parent has already consumed its own count and a running child is reporting no work units. The resulting Count > Total value surfaces as a >100% progress bar in the dashboard. Add a single-line clamp so Count never exceeds Total, and pin the behavior with TestProgress_ZeroTotalChildDoesNotExceed100Percent.
3d5b707 to
7af1a6a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1243 +/- ##
==========================================
+ Coverage 73.05% 73.09% +0.03%
==========================================
Files 89 89
Lines 16651 16653 +2
==========================================
+ Hits 12165 12173 +8
+ Misses 3247 3242 -5
+ Partials 1239 1238 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Problem
After #1208 removed the divide-by-zero panic in
Span.Progress, the "zero-total child is complete" fallback can pushparentCountaboveparentTotalwhen the parent has already consumed its own count and a running child is reporting zero total.With a parent
total=2, count=2plus one running child withtotal=0,Span.Progress()returnsProgress{Count: 3, Total: 2}. The dashboard progress bar at/api/dashboard/tasksrenders this as 150%.Root Cause
common/monitor/progress.go:138-169:When
s.count * childTotal == parentTotaland the zero-total branch fires,parentCountexceedsparentTotalby onechildTotalunit. There is no clamp before theProgress{}value is returned.Solution
Clamp
parentCounttoparentTotaljust before returning:This is the minimal change that keeps the "zero-total child is complete" semantics from #1208 while restoring the
0 <= Count <= Totalinvariant.Testing
New pinning test in
common/monitor/progress_overflow_test.go:Count (3) exceeds Total (2).common/monitortests (includingTestProgress/divide_by_zero,TestProgress/child_with_zero_total,TestProgress/all_children_with_zero_totaladded in Fix divide by zero in progress calculation #1208) still pass.Scope
Single-hunk fix plus a targeted regression test. No behavioural change for the non-overflowing cases; the clamp only engages on the exact scenario #1208 could not reach.
Fixes #1241