Commit f18f05f
authored
fix(orchestrator): measure ext4 free space from block groups (#3282)
The ensure-free-disk phase previously trusted debugfs's top-level "Free
blocks" value, which comes from the ext4 superblock. After an unclean
shutdown, Linux can leave this aggregate stale, and e2fsck -E
journal_only returns before rebuilding it from the block-group
descriptors. This could cause builds to make an incorrect resize
decision and leave less free space than requested.
Flush the NBD device after replaying the journal, then calculate free
space by summing debugfs's per-group counters and subtracting reserved
blocks. Require one counter for every group so incomplete or unexpected
output fails instead of silently producing an incorrect result. Pin
LC_ALL=C because the parser relies on debugfs's English field names.
Add Linux unit coverage for stale global counters, multi-group sums,
singular block output, incomplete group output, and global-only output.1 parent 69c06b6 commit f18f05f
3 files changed
Lines changed: 60 additions & 20 deletions
File tree
- packages/orchestrator/pkg/template/build
- core/filesystem
- phases/ensurefreedisk
Lines changed: 32 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
196 | 202 | | |
197 | 203 | | |
198 | 204 | | |
| 205 | + | |
| 206 | + | |
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| |||
206 | 214 | | |
207 | 215 | | |
208 | 216 | | |
209 | | - | |
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
| |||
376 | 383 | | |
377 | 384 | | |
378 | 385 | | |
379 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
380 | 394 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
385 | 401 | | |
386 | | - | |
387 | | - | |
388 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
389 | 410 | | |
390 | 411 | | |
391 | 412 | | |
392 | 413 | | |
393 | 414 | | |
394 | | - | |
| 415 | + | |
395 | 416 | | |
396 | | - | |
397 | | - | |
| 417 | + | |
398 | 418 | | |
399 | 419 | | |
400 | 420 | | |
| |||
Lines changed: 23 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | | - | |
33 | | - | |
| 47 | + | |
| 48 | + | |
34 | 49 | | |
35 | 50 | | |
36 | 51 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| |||
0 commit comments