diff options
author | Avan Thakkar <athakkar@redhat.com> | 2024-09-13 16:11:47 +0200 |
---|---|---|
committer | Avan Thakkar <athakkar@redhat.com> | 2024-09-25 14:06:10 +0200 |
commit | 24af1beeb54c4c014bb374211152108d2b690e1a (patch) | |
tree | 8987c323eee5a6eae67d4e7b0a4ca5267e022f0b /src/python-common | |
parent | mgr/nfs: earmark resolver for subvolume (diff) | |
download | ceph-24af1beeb54c4c014bb374211152108d2b690e1a.tar.xz ceph-24af1beeb54c4c014bb374211152108d2b690e1a.zip |
earmarking: improve error handling when getxattr fails
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
Diffstat (limited to 'src/python-common')
-rw-r--r-- | src/python-common/ceph/fs/earmarking.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/python-common/ceph/fs/earmarking.py b/src/python-common/ceph/fs/earmarking.py index 238f2d8755f..c5d4a59a4d5 100644 --- a/src/python-common/ceph/fs/earmarking.py +++ b/src/python-common/ceph/fs/earmarking.py @@ -61,11 +61,16 @@ class CephFSVolumeEarmarking: if isinstance(e, ValueError): raise EarmarkException(errno.EINVAL, f"Invalid earmark specified: {e}") from e elif isinstance(e, OSError): - log.error(f"Error {action} earmark: {e}") - raise EarmarkException(-e.errno, e.strerror) from e + if e.errno == errno.ENODATA: + # Return empty string when earmark is not set + log.info(f"No earmark set for the path while {action}. Returning empty result.") + return '' + else: + log.error(f"Error {action} earmark: {e}") + raise EarmarkException(-e.errno, e.strerror) from e else: log.error(f"Unexpected error {action} earmark: {e}") - raise EarmarkException + raise EarmarkException(errno.EFAULT, f"Unexpected error {action} earmark: {e}") from e @staticmethod def parse_earmark(value: str) -> Optional[EarmarkContents]: @@ -128,8 +133,7 @@ class CephFSVolumeEarmarking: ) return earmark_value except Exception as e: - self._handle_cephfs_error(e, "getting") - return None + return self._handle_cephfs_error(e, "getting") def set_earmark(self, earmark: str): # Validate the earmark before attempting to set it |