From: Venky Shankar Date: Fri, 5 Jul 2019 09:50:42 +0000 (-0400) Subject: mgr / volumes: use negative error codes everywhere X-Git-Tag: v14.2.3~168^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3aee03a0ffdcdeff7f354af53171174a864d0d7b;p=ceph.git mgr / volumes: use negative error codes everywhere cephfs python binding returns positive error code. mgr/volumes incorrectly does error code checks assuming the error codes to be negative. this was not an issue till now since mgr/volumes mostly does a `raise VolumeException()` for the most part followed by the exception being displayed to the operator (one exception is catching cephfs ObjectNotFound error, in which case -errno.ENOENT is returned (and checked whereever required)). Signed-off-by: Venky Shankar (cherry picked from commit dd569e22e8d1b6287207fb2d1a4269d0bef20784) --- diff --git a/src/pybind/mgr/volumes/fs/subvolume.py b/src/pybind/mgr/volumes/fs/subvolume.py index 6a647b8c44478..1c47e947716e7 100644 --- a/src/pybind/mgr/volumes/fs/subvolume.py +++ b/src/pybind/mgr/volumes/fs/subvolume.py @@ -54,7 +54,7 @@ class SubVolume(object): except cephfs.ObjectNotFound: self.fs.mkdir(subpath, mode) except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) def _get_single_dir_entry(self, dir_path, exclude=[]): """ @@ -147,7 +147,7 @@ class SubVolume(object): raise VolumeException( -errno.ENOENT, "Subvolume '{0}' not found, cannot remove it".format(spec.subvolume_id)) except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) def purge_subvolume(self, spec, should_cancel): """ @@ -161,7 +161,7 @@ class SubVolume(object): except cephfs.ObjectNotFound: return except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) d = self.fs.readdir(dir_handle) while d and not should_cancel(): d_name = d.d_name.decode('utf-8') @@ -192,7 +192,7 @@ class SubVolume(object): except cephfs.ObjectNotFound: return None except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) return path ### group operations @@ -212,7 +212,7 @@ class SubVolume(object): if not force: raise VolumeException(-errno.ENOENT, "Subvolume group '{0}' not found".format(spec.group_id)) except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) def get_group_path(self, spec): path = spec.group_path @@ -246,7 +246,7 @@ class SubVolume(object): except cephfs.ObjectNotFound: self.fs.mkdir(snappath, mode) except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) else: log.warn("Snapshot '{0}' already exists".format(snappath)) @@ -261,7 +261,7 @@ class SubVolume(object): if not force: raise VolumeException(-errno.ENOENT, "Snapshot '{0}' not found, cannot remove it".format(snappath)) except cephfs.Error as e: - raise VolumeException(e.args[0], e.args[1]) + raise VolumeException(-e.args[0], e.args[1]) def create_subvolume_snapshot(self, spec, snapname, mode=0o755): snappath = spec.make_subvol_snap_path(self.rados.conf_get('client_snapdir'), snapname)