]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr / volumes: use negative error codes everywhere
authorVenky Shankar <vshankar@redhat.com>
Fri, 5 Jul 2019 09:50:42 +0000 (05:50 -0400)
committerVenky Shankar <vshankar@redhat.com>
Mon, 8 Jul 2019 03:58:16 +0000 (23:58 -0400)
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 <vshankar@redhat.com>
src/pybind/mgr/volumes/fs/subvolume.py

index dba8201419acb2b797347a471881ebbfab4827bc..39018b566b4e95a77d10fe917674f5f71c3d4d4a 100644 (file)
@@ -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)