diff options
author | Allan Jude <[email protected]> | 2020-08-01 11:41:31 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-01 08:41:31 -0700 |
commit | 8fb79fdddb076036a006e19f4e1b93b3baf72498 (patch) | |
tree | 9327b9f3a9b6dd1efb12778e74de7a34567f1856 /contrib/pyzfs | |
parent | 47ed79ff60945e0c5d8ccb56f0d29a893e1261ac (diff) |
Change the error handling for invalid property values
ZFS recv should return a useful error message when an invalid index
property value is provided in the send stream properties nvlist
With a compression= property outside of the understood range:
Before:
```
receiving full stream of zof/zstd_send@send2 into testpool/recv@send2
internal error: Invalid argument
Aborted (core dumped)
```
Note: the recv completes successfully, the abort() is likely just to
make it easier to track the unexpected error code.
After:
```
receiving full stream of zof/zstd_send@send2 into testpool/recv@send2
cannot receive compression property on testpool/recv: invalid property
value received 28.9M stream in 1 seconds (28.9M/sec)
```
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Allan Jude <[email protected]>
Closes #10631
Diffstat (limited to 'contrib/pyzfs')
-rw-r--r-- | contrib/pyzfs/libzfs_core/_constants.py | 2 | ||||
-rw-r--r-- | contrib/pyzfs/libzfs_core/_error_translation.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/contrib/pyzfs/libzfs_core/_constants.py b/contrib/pyzfs/libzfs_core/_constants.py index 367ffb63a..2dfed224c 100644 --- a/contrib/pyzfs/libzfs_core/_constants.py +++ b/contrib/pyzfs/libzfs_core/_constants.py @@ -98,6 +98,7 @@ zfs_errno = enum_with_offset(1024, [ 'ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH', 'ZFS_ERR_RESILVER_IN_PROGRESS', 'ZFS_ERR_REBUILD_IN_PROGRESS', + 'ZFS_ERR_BADPROP', ], {} ) @@ -110,5 +111,4 @@ ZFS_ERR_DEVRM_IN_PROGRESS = zfs_errno.ZFS_ERR_DEVRM_IN_PROGRESS ZFS_ERR_VDEV_TOO_BIG = zfs_errno.ZFS_ERR_VDEV_TOO_BIG ZFS_ERR_WRONG_PARENT = zfs_errno.ZFS_ERR_WRONG_PARENT - # vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4 diff --git a/contrib/pyzfs/libzfs_core/_error_translation.py b/contrib/pyzfs/libzfs_core/_error_translation.py index 5a063c714..f494461f6 100644 --- a/contrib/pyzfs/libzfs_core/_error_translation.py +++ b/contrib/pyzfs/libzfs_core/_error_translation.py @@ -59,6 +59,8 @@ def lzc_create_translate_error(ret, name, ds_type, props): raise lzc_exc.ParentNotFound(name) if ret == ZFS_ERR_WRONG_PARENT: raise lzc_exc.WrongParent(_fs_name(name)) + if ret == zfs_errno.ZFS_ERR_BADPROP: + raise lzc_exc.PropertyInvalid(name) raise _generic_exception(ret, name, "Failed to create filesystem") @@ -420,6 +422,8 @@ def lzc_receive_translate_errors( def _map(ret, name): if ret == errno.EINVAL: return lzc_exc.PropertyInvalid(name) + if ret == zfs_errno.ZFS_ERR_BADPROP: + return lzc_exc.PropertyInvalid(name) return _generic_exception(ret, name, "Failed to set property") _handle_err_list( errno.EINVAL, properrs, [snapname], @@ -471,6 +475,8 @@ def lzc_receive_translate_errors( raise lzc_exc.WrongParent(_fs_name(snapname)) if ret == zfs_errno.ZFS_ERR_STREAM_TRUNCATED: raise lzc_exc.StreamTruncated() + if ret == zfs_errno.ZFS_ERR_BADPROP: + raise lzc_exc.PropertyInvalid(snapname) raise lzc_exc.StreamIOError(ret) |