Commit 694a22e
committed
Fix
### What does this PR do?
Fix `fetch_main_headroom()` in tasks/static_quality_gates/metrics.py so
`quality-gates.exception-threshold-bump` actually restores headroom
instead of reproducing `main`'s own failure.
Widen its lookback window from 1 day to 7 so it doesn't miss `main`'s
last report when no commit lands over a weekend.
Floor the computed headroom at `BUFFER_SIZE` instead of 0 when main is
already over its own limit, since `max - current` is then negative and
previously clamped straight to 0.
### Motivation
`static_quality_gates` has been failing by a handful of KB on at least 3
[unrelated PRs last week](https://dd.slack.com/archives/C08SK4B0FK8/p1786035443536819)
and on `main` itself: `agent_rpm_arm64` and `agent_suse_arm64` both
exceeded their 735.07 MiB limit after #52372 and #54319 landed.
Main's own headroom was already at or below 0 for these gates, so
`exception-threshold-bump`'s formula, `new_threshold = PR_current +
main_headroom`, reduced to just PR_current: it silently produced a
threshold still below main's actual usage, which would not even have
unblocked `main`.
Separately, `fetch_main_headroom()`'s 1-day lookback returned no data
at all across the weekend gap between Friday's merges and Monday's
incident, since main only reports this metric when a commit lands.
### Describe how you validated your changes
Added `test_headroom_floored_when_main_over_its_own_limit` (renamed
from the now-inverted `test_headroom_never_negative`) asserting the
floor applies when main is over budget.
Reran `quality-gates.exception-threshold-bump` twice independently: both
runs produced identical thresholds (`agent_rpm_arm64/agent_suse_arm64`
-> 736.03 MiB, `iot_agent_deb/rpm/suse_amd64` -> 47.33 MiB), confirming
the fix is deterministic.
### Additional Notes
This restores headroom but does not address recurring growths that
disregard earlier efforts.exception-threshold-bump and restore lost headroom1 parent b1e8c38 commit 694a22e
3 files changed
Lines changed: 35 additions & 30 deletions
File tree
- tasks
- static_quality_gates
- unit_tests/static_quality_gates
- test/static
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
| 137 | + | |
134 | 138 | | |
135 | | - | |
136 | | - | |
| 139 | + | |
| 140 | + | |
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
251 | | - | |
252 | | - | |
| 252 | + | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
281 | | - | |
| 281 | + | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
| 47 | + | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
0 commit comments