Repository navigation
resize: EVE-patterned resume tests and SIGKILL chaos harness #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
deitch
merged 13 commits into
diskfs:main
from
eriknordmark:updatepartitions-idempotent
Jun 19, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
85d0493
test: scaled mixed-layout resume tests
eriknordmark 12f95d8
test: log GPT partition table at each resize stage
eriknordmark 59ba7d8
test: resize stress tests (kill/resume chaos + invariants)
eriknordmark 90419f5
test: chaos test does full two-step shrink+grow with kill recording
eriknordmark c5acac1
test: chaos GPT-write-delay hook to hit updatePartitions
eriknordmark 0799e7c
test: record GPT integrity after each chaos kill
eriknordmark 79439a7
test: optional copy-dest state check after a kill
eriknordmark 8533c16
test: make chaos soak test opt-in and document it
eriknordmark 73ed80b
ci: raise test timeout to 45m for the end-to-end suite
eriknordmark 8a36624
test: use real EVE GPT labels in sample layout
eriknordmark ab20cbe
test: assert updatePartitions preserves GPT attributes
eriknordmark 361ca09
run: work against real block devices
eriknordmark f5ce0e9
resize: reboot-to-apply on a deferred re-read
eriknordmark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package partitionresizer | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "os" | ||
| "sort" | ||
| "strings" | ||
| ) | ||
|
|
||
| // copyDestState classifies each "<label>_resized2" grow target's data region to | ||
| // distinguish "nothing written" from a partial or complete copy -- the certain | ||
| // empty-vs-something signal the KILL_STEP marker alone cannot give. For a | ||
| // raw-copied source (squashfs/unknown) it compares the target's head and tail to | ||
| // the source: a head mismatch means nothing was copied, head match + tail | ||
| // mismatch means partial, both match means complete. For a filesystem copy | ||
| // (FAT32/ext4) a byte compare is meaningless (fresh metadata differs), so it | ||
| // looks for that filesystem's on-disk signature, which CreateFilesystem writes | ||
| // before any file data -- present means something was written. | ||
| // | ||
| // It locates partitions with gptPartitions (a raw entry-array read) for the same | ||
| // reason as the other helpers in gpt_raw_test.go: it runs on a post-kill disk | ||
| // whose table may be torn. | ||
| func copyDestState(path string) string { | ||
| f, err := os.Open(path) | ||
| if err != nil { | ||
| return "copydest:open-error" | ||
| } | ||
| defer func() { _ = f.Close() }() | ||
| parts := gptPartitions(f) | ||
| if parts == nil { | ||
| return "copydest:no-gpt" | ||
| } | ||
| const chunk = 4096 | ||
| var states []string | ||
| for label, tgt := range parts { | ||
| if !strings.HasSuffix(label, alternateLabelSuffix) { | ||
| continue | ||
| } | ||
| src, ok := parts[strings.TrimSuffix(label, alternateLabelSuffix)] | ||
| if !ok { | ||
| states = append(states, label+"=no-source") | ||
| continue | ||
| } | ||
| srcStart := src[0] * 512 | ||
| srcLen := (src[1] - src[0] + 1) * 512 | ||
| tgtStart := tgt[0] * 512 | ||
| srcHead, tgtHead := readAt(f, srcStart, chunk), readAt(f, tgtStart, chunk) | ||
| var state string | ||
| switch { | ||
| case srcHead == nil || tgtHead == nil: | ||
| state = "read-error" | ||
| case len(srcHead) >= 4 && string(srcHead[0:4]) == "hsqs": // squashfs => raw copy | ||
| switch { | ||
| case !bytes.Equal(srcHead, tgtHead): | ||
| state = "empty" | ||
| case srcLen <= chunk: | ||
| state = "complete" | ||
| default: | ||
| to := srcLen - chunk | ||
| if bytes.Equal(readAt(f, srcStart+to, chunk), readAt(f, tgtStart+to, chunk)) { | ||
| state = "complete" | ||
| } else { | ||
| state = "partial" | ||
| } | ||
| } | ||
| default: // FAT32/ext4 => filesystem copy; detect the target's fs signature | ||
| fat := len(tgtHead) >= 512 && tgtHead[510] == 0x55 && tgtHead[511] == 0xAA | ||
| ext4sb := readAt(f, tgtStart+1024, 512) | ||
| ext4 := len(ext4sb) >= 58 && ext4sb[56] == 0x53 && ext4sb[57] == 0xEF | ||
| if fat || ext4 { | ||
| state = "written" | ||
| } else { | ||
| state = "empty" | ||
| } | ||
| } | ||
| states = append(states, label+"="+state) | ||
| } | ||
| sort.Strings(states) | ||
| return "copydest: " + strings.Join(states, " ") | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //go:build chaos | ||
|
|
||
| package partitionresizer | ||
|
|
||
| import ( | ||
| "os" | ||
| "time" | ||
|
|
||
| "github.com/diskfs/go-diskfs/backend" | ||
| ) | ||
|
|
||
| // maybeWrapBackend, in -tags chaos builds, wraps the backend so that a write | ||
| // touching a GPT metadata sector is followed by a delay | ||
| // (RESIZER_GPT_WRITE_DELAY, e.g. "10s"). go-diskfs writes the table as several | ||
| // WriteAt calls (backup entries, backup header, primary entries, primary | ||
| // header, protective MBR); the delay widens the window between them so a | ||
| // crash-injection test can land between the backup and primary writes -- in | ||
| // particular inside updatePartitions, which is otherwise a single fast table | ||
| // write that random-timed kills almost never catch. | ||
| func maybeWrapBackend(b backend.Storage) backend.Storage { | ||
| s := os.Getenv("RESIZER_GPT_WRITE_DELAY") | ||
| if s == "" { | ||
| return b | ||
| } | ||
| d, err := time.ParseDuration(s) | ||
| if err != nil || d <= 0 { | ||
| return b | ||
| } | ||
| var sectors int64 | ||
| if fi, serr := b.Stat(); serr == nil { | ||
| sectors = fi.Size() / 512 | ||
| } | ||
| return &delayBackend{Storage: b, delay: d, diskSectors: sectors} | ||
| } | ||
|
|
||
| type delayBackend struct { | ||
| backend.Storage | ||
| delay time.Duration | ||
| diskSectors int64 | ||
| } | ||
|
|
||
| func (d *delayBackend) Writable() (backend.WritableFile, error) { | ||
| wf, err := d.Storage.Writable() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &delayWritable{WritableFile: wf, delay: d.delay, diskSectors: d.diskSectors}, nil | ||
| } | ||
|
|
||
| type delayWritable struct { | ||
| backend.WritableFile | ||
| delay time.Duration | ||
| diskSectors int64 | ||
| } | ||
|
|
||
| func (d *delayWritable) WriteAt(p []byte, off int64) (int, error) { | ||
| n, err := d.WritableFile.WriteAt(p, off) | ||
| if err == nil && isGPTWrite(off, len(p), d.diskSectors) { | ||
| time.Sleep(d.delay) | ||
| } | ||
| return n, err | ||
| } | ||
|
|
||
| // isGPTWrite reports whether a write at byte offset off of the given length | ||
| // touches a GPT metadata sector (512-byte LBAs): the protective MBR + primary | ||
| // header + primary entry array (LBA 0..33), or the backup entry array + backup | ||
| // header (the last 33 sectors). | ||
| func isGPTWrite(off int64, length int, diskSectors int64) bool { | ||
| const sec = 512 | ||
| start := off / sec | ||
| end := (off + int64(length) - 1) / sec | ||
| if start <= 33 { // overlaps the primary region (LBA 0..33) | ||
| return true | ||
| } | ||
| if diskSectors > 0 && end >= diskSectors-33 { // overlaps the backup region | ||
| return true | ||
| } | ||
| return false | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //go:build !chaos | ||
|
|
||
| package partitionresizer | ||
|
|
||
| import "github.com/diskfs/go-diskfs/backend" | ||
|
|
||
| // maybeWrapBackend returns the backend unchanged in normal builds. The delaying | ||
| // wrapper exists only in -tags chaos builds (see delaybackend_chaos.go), so | ||
| // production binaries carry none of that code. | ||
| func maybeWrapBackend(b backend.Storage) backend.Storage { return b } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.