]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Don't perform retry_execute in certain cases.
authorJohn Griffith <john.griffith@solidfire.com>
Tue, 18 Jun 2013 20:45:50 +0000 (14:45 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Wed, 19 Jun 2013 22:11:23 +0000 (16:11 -0600)
Certain cases like "LVM not found" and "Insufficient space"
in LVM create/delete shouldn't be retried.

Change-Id: I1a0891f769d37dc858c70b07c838f9fc4111a76c

cinder/volume/driver.py
cinder/volume/drivers/lvm.py

index 90b0e6d9ea50cecab19a75aff49c426dfa6cc137..5033a56a74feadee62dde482c02fd238be98e992 100644 (file)
@@ -78,19 +78,32 @@ class VolumeDriver(object):
     def set_execute(self, execute):
         self._execute = execute
 
+    def _is_non_recoverable(self, err, non_recoverable_list):
+        for item in non_recoverable_list:
+            if item in err:
+                return True
+
+        return False
+
     def _try_execute(self, *command, **kwargs):
         # NOTE(vish): Volume commands can partially fail due to timing, but
         #             running them a second time on failure will usually
         #             recover nicely.
+
+        non_recoverable = kwargs.pop('no_retry_list', [])
+
         tries = 0
         while True:
             try:
                 self._execute(*command, **kwargs)
                 return True
-            except exception.ProcessExecutionError:
+            except exception.ProcessExecutionError as ex:
                 tries = tries + 1
-                if tries >= self.configuration.num_shell_tries:
+
+                if tries >= self.configuration.num_shell_tries or\
+                        self._is_non_recoverable(ex.stderr, non_recoverable):
                     raise
+
                 LOG.exception(_("Recovering from a failed execute.  "
                                 "Try number %s"), tries)
                 time.sleep(tries ** 2)
@@ -555,6 +568,9 @@ class FakeISCSIDriver(ISCSIDriver):
         super(FakeISCSIDriver, self).__init__(execute=self.fake_execute,
                                               *args, **kwargs)
 
+    def create_volume(self, volume):
+        pass
+
     def check_for_setup_error(self):
         """No setup necessary in fake mode."""
         pass
index 3c214cc5f5d586094251f329f548a5c82536cf7b..fbb3f2bbe06af08d516d405c37a2e358b7e597dc 100644 (file)
@@ -84,6 +84,10 @@ class LVMVolumeDriver(driver.VolumeDriver):
             raise exception.VolumeBackendAPIException(data=exception_message)
 
     def _create_volume(self, volume_name, sizestr):
+
+        no_retry_list = ['Insufficient free extents',
+                         'One or more specified logical volume(s) not found']
+
         cmd = ['lvcreate', '-L', sizestr, '-n', volume_name,
                self.configuration.volume_group]
         if self.configuration.lvm_mirrors:
@@ -95,7 +99,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
                 #             http://red.ht/U2BPOD
                 cmd += ['-R', str(rsize)]
 
-        self._try_execute(*cmd, run_as_root=True)
+        self._try_execute(*cmd, run_as_root=True, no_retry_list=no_retry_list)
 
     def _copy_volume(self, srcstr, deststr, size_in_g, clearing=False):
         # Use O_DIRECT to avoid thrashing the system buffer cache