Skip to content

Commit

Permalink
Merge pull request #115 from vansante/add-suspend-err
Browse files Browse the repository at this point in the history
Add pool I/O suspended error
  • Loading branch information
vansante authored Jan 8, 2025
2 parents d6fad73 + ce9b16d commit 254028e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
datasetNotFoundMessage = "dataset does not exist"
resumableErrorMessage = "resuming stream can be generated on the sending system"
datasetBusyMessage = "pool or dataset is busy"
poolIOSuspendedMessage = "pool I/O is currently suspended"
datasetNoLongerExistsMessage = "no longer exists"
snapshotHasDependentsMessage = "snapshot has dependent clones"
keyAlreadyLoadedMessage = "Key already loaded for"
Expand All @@ -36,6 +37,9 @@ var (
// ErrPoolOrDatasetBusy is returned when an action fails because ZFS is doing another action
ErrPoolOrDatasetBusy = errors.New("pool or dataset busy")

// ErrPoolIOSuspended is returned when the ZPool has been suspended
ErrPoolIOSuspended = errors.New("pool I/O suspended")

// ErrSnapshotHasDependentClones is returned when the snapshot has dependent clones
ErrSnapshotHasDependentClones = errors.New("snapshot has dependent clones")

Expand Down Expand Up @@ -75,6 +79,8 @@ func createError(cmd *exec.Cmd, stderr string, err error) error {
stderr = stderr[:idx]
}
return fmt.Errorf("%s: %w", stderr, ErrPoolOrDatasetBusy)
case strings.Contains(stderr, poolIOSuspendedMessage):
return fmt.Errorf("%s: %w", stderr, ErrPoolIOSuspended)
case strings.Contains(stderr, datasetNoLongerExistsMessage):
return fmt.Errorf("%s: %w", stderr, ErrDatasetNotFound)
case strings.Contains(stderr, datasetExistsMessage1) && strings.Contains(stderr, datasetExistsMessage2):
Expand Down
4 changes: 2 additions & 2 deletions zfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func TestDatasetGetProperty(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "off", prop)

prop, err = ds.GetProperty(context.Background(), PropertyCompression)
prop, err = ds.GetProperty(context.Background(), PropertyMounted)
require.NoError(t, err)
require.Equal(t, "off", prop)
require.Equal(t, ValueYes, prop)
})
}

Expand Down

0 comments on commit 254028e

Please sign in to comment.