From: Venky Shankar Date: Fri, 5 Jul 2019 09:50:42 +0000 (-0400) Subject: mgr / volumes: use negative error codes everywhere X-Git-Tag: v15.1.0~2189^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dd569e22e8d1b6287207fb2d1a4269d0bef20784;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 --- diff --git a/src/pybind/mgr/volumes/fs/subvolume.py b/src/pybind/mgr/volumes/fs/subvolume.py index dba8201419ac..39018b566b4e 100644 --- a/src/pybind/mgr/volumes/fs/subvolume.py +++ b/src/pybind/mgr/volumes/fs/subvolume.py @@ -57,7 +57,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]) ### basic subvolume operations @@ -125,7 +125,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): """ @@ -140,7 +140,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: d_name = d.d_name.decode('utf-8') @@ -168,7 +168,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 @@ -188,7 +188,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 @@ -222,7 +222,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)) @@ -237,7 +237,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)