]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix up failover_host exceptions to preserve states
authorAlex O'Rourke <alex.orourke@hpe.com>
Thu, 10 Mar 2016 21:33:20 +0000 (13:33 -0800)
committerAlex O'Rourke <alex.orourke@hpe.com>
Thu, 10 Mar 2016 22:48:34 +0000 (14:48 -0800)
UnableToFailOver and InvalidReplicationTarget do not save the state
of replication_status currently. This patch adds host.save() in
order to write the change to the db.

In addition, the manager should honor the current replication state
of the host when InvalidReplicationTarget is raised instead of forcing
it into 'enabled' state.

Change-Id: I01af6d70539e518936c74e425c3fad60f4b94581

cinder/volume/manager.py

index 9c124ad6a1886f5f1958fda980a02362014e077c..c39f2763a976a65857ff7710496f8cd1788267c2 100644 (file)
@@ -3297,11 +3297,18 @@ class VolumeManager(manager.SchedulerDependentManager):
             LOG.exception(_LE("Failed to perform replication failover"))
             service.replication_status = (
                 fields.ReplicationStatus.FAILOVER_ERROR)
+            service.save()
             exception_encountered = True
         except exception.InvalidReplicationTarget:
             LOG.exception(_LE("Invalid replication target specified "
                               "for failover"))
-            service.replication_status = fields.ReplicationStatus.ENABLED
+            # Preserve the replication_status
+            if secondary_backend_id == "default":
+                service.replication_status = (
+                    fields.ReplicationStatus.FAILED_OVER)
+            else:
+                service.replication_status = fields.ReplicationStatus.ENABLED
+            service.save()
             exception_encountered = True
         except exception.VolumeDriverException:
             # NOTE(jdg): Drivers need to be aware if they fail during