]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Don't stop volume service for failed re-export operations
authorEric Harney <eharney@redhat.com>
Mon, 2 Dec 2013 19:58:57 +0000 (14:58 -0500)
committerEric Harney <eharney@redhat.com>
Mon, 2 Dec 2013 20:15:37 +0000 (15:15 -0500)
Commit b71570 "Set vol driver initialized before deleting volumes"
changed the manager behavior to call set_initialized() before
attempting to re-export volumes.

Drivers should not be considered initialized before re-export has
succeeded.  Otherwise a failure to export causes the volume
service to stop, when that failure should be handled like any other
failure to initialize.

Closes-Bug: 1257049
Related-Bug: 1232177
Change-Id: Ic6bc89ef3f15dbbc971fdd8c91117cccb5c2801b

cinder/volume/manager.py

index fcfd80dc82b897121ddf7e7a4abc0c7516044518..413311ba57f0e9bd9ffe308f5fdcef375992ec4c 100644 (file)
@@ -198,23 +198,32 @@ class VolumeManager(manager.SchedulerDependentManager):
             # to initialize the driver correctly.
             return
 
-        # at this point the driver is considered initailized.
-        # next re-initialize exports and clean up volumes that
-        # should be deleted.
-        self.driver.set_initialized()
-
         volumes = self.db.volume_get_all_by_host(ctxt, self.host)
         LOG.debug(_("Re-exporting %s volumes"), len(volumes))
-        for volume in volumes:
-            if volume['status'] in ['available', 'in-use']:
-                self.driver.ensure_export(ctxt, volume)
-            elif volume['status'] == 'downloading':
-                LOG.info(_("volume %s stuck in a downloading state"),
-                         volume['id'])
-                self.driver.clear_download(ctxt, volume)
-                self.db.volume_update(ctxt, volume['id'], {'status': 'error'})
-            else:
-                LOG.info(_("volume %s: skipping export"), volume['id'])
+
+        try:
+            for volume in volumes:
+                if volume['status'] in ['available', 'in-use']:
+                    self.driver.ensure_export(ctxt, volume)
+                elif volume['status'] == 'downloading':
+                    LOG.info(_("volume %s stuck in a downloading state"),
+                             volume['id'])
+                    self.driver.clear_download(ctxt, volume)
+                    self.db.volume_update(ctxt,
+                                          volume['id'],
+                                          {'status': 'error'})
+                else:
+                    LOG.info(_("volume %s: skipping export"), volume['id'])
+        except Exception as ex:
+            LOG.error(_("Error encountered during "
+                        "re-exporting phase of driver initialization: "
+                        " %(name)s") %
+                      {'name': self.driver.__class__.__name__})
+            LOG.exception(ex)
+            return
+
+        # at this point the driver is considered initialized.
+        self.driver.set_initialized()
 
         LOG.debug(_('Resuming any in progress delete operations'))
         for volume in volumes: