From 2e70ef0bea975491299c3b9d746012cf53766848 Mon Sep 17 00:00:00 2001 From: Paul van Santen Date: Wed, 8 Jan 2025 15:11:01 +0100 Subject: [PATCH 1/2] Add pool I/O suspended error --- error.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/error.go b/error.go index e8ab079..d190f9c 100644 --- a/error.go +++ b/error.go @@ -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" @@ -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") @@ -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): From ce9b16d8102af3d501717f73477c8efed7ccf4ef Mon Sep 17 00:00:00 2001 From: Paul van Santen Date: Wed, 8 Jan 2025 15:18:52 +0100 Subject: [PATCH 2/2] Adjust failing test --- zfs_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zfs_test.go b/zfs_test.go index ee4d6bd..39784ab 100644 --- a/zfs_test.go +++ b/zfs_test.go @@ -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) }) }