Skip to content

Commit

Permalink
Merge pull request #266 from truenas/fix-exception-pickle
Browse files Browse the repository at this point in the history
NAS-128563 / 24.10 / Fix ZFS exceptions unpickle
  • Loading branch information
themylogin authored Apr 26, 2024
2 parents 2021600 + 3ee341e commit 7b2f1eb
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions libzfs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,18 @@ class ZFSException(RuntimeError):


class ZFSVdevStatsException(ZFSException):
def __init__(self, code):
super(ZFSVdevStatsException, self).__init__(code, 'Failed to fetch ZFS Vdev Stats')
def __init__(self, code, message='Failed to fetch ZFS Vdev Stats'):
super(ZFSVdevStatsException, self).__init__(code, message)


class ZFSPoolRaidzExpandStatsException(ZFSException):
def __init__(self, code):
super(ZFSPoolRaidzExpandStatsException, self).__init__(code, 'Failed to retrieve ZFS pool scan stats')
def __init__(self, code, message='Failed to retrieve ZFS pool scan stats'):
super(ZFSPoolRaidzExpandStatsException, self).__init__(code, message)


class ZFSPoolScanStatsException(ZFSException):
def __init__(self, code):
super(ZFSPoolScanStatsException, self).__init__(code, 'Failed to retrieve ZFS pool scan stats')
def __init__(self, code, message='Failed to retrieve ZFS pool scan stats'):
super(ZFSPoolScanStatsException, self).__init__(code, message)


cdef class ZFS(object):
Expand Down Expand Up @@ -2805,6 +2805,16 @@ cdef class ZFSPool(object):

filter_vdevs = [zfs.VDEV_TYPE_HOLE, zfs.VDEV_TYPE_INDIRECT]

try:
scan = self.scrub.asdict()
except ZFSPoolScanStatsException:
scan = None

try:
expand = self.expand.asdict()
except ZFSPoolRaidzExpandStatsException:
expand = None

state = {
'name': self.name,
'id': self.name,
Expand All @@ -2817,8 +2827,8 @@ cdef class ZFSPool(object):
'root_dataset': root_ds,
'properties': {k: p.asdict() for k, p in self.properties.items()} if self.properties else None,
'features': [i.asdict() for i in self.features] if self.features else None,
'scan': self.scrub.asdict(),
'expand': self.expand.asdict(),
'scan': scan,
'expand': expand,
'root_vdev': self.root_vdev.asdict(False),
'groups': {
'data': [i.asdict() for i in self.data_vdevs if i.type not in filter_vdevs],
Expand Down

0 comments on commit 7b2f1eb

Please sign in to comment.