zfs: fix platformtest compat with ZFS 2.3 & 2.4 (#922)
The error message when destroying a held snapshot no longer is `dataset is busy` but `it's being held. Run 'zfs holds -r <snapshot>' to see holders.` The existing `destroySnapshotsErrorRegexp` parses both formats correctly, but downstream test assertions in platformtest were checking for the literal `dataset is busy` string. refs - the PR that adds ZFS 2.3 & 2.4 to CI: https://github.com/zrepl/zrepl/pull/921 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
c393f35453
commit
1dfae6829b
@@ -1723,6 +1723,20 @@ type DestroySnapshotsError struct {
|
||||
Reason []string
|
||||
}
|
||||
|
||||
var destroySnapshotsReasonHeldRegexp = regexp.MustCompile(`^it's being held\. Run 'zfs holds -r .+' to see holders\.$`)
|
||||
|
||||
// AllReasonIsHold returns true if every undestroyable snapshot failed because
|
||||
// it is held. ZFS < 2.4 reports "dataset is busy", ZFS >= 2.4 reports
|
||||
// "it's being held. Run 'zfs holds -r <snapshot>' to see holders."
|
||||
func (e *DestroySnapshotsError) AllReasonIsHold() bool {
|
||||
for _, r := range e.Reason {
|
||||
if r != "dataset is busy" && !destroySnapshotsReasonHeldRegexp.MatchString(r) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *DestroySnapshotsError) Error() string {
|
||||
if len(e.Undestroyable) != len(e.Reason) {
|
||||
panic(fmt.Sprintf("%v != %v", len(e.Undestroyable), len(e.Reason)))
|
||||
|
||||
Reference in New Issue
Block a user