From: Alex O'Rourke Date: Thu, 10 Mar 2016 21:33:20 +0000 (-0800) Subject: Fix up failover_host exceptions to preserve states X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2dbd05452c4be3ea13f04571a8f821d228449197;p=openstack-build%2Fcinder-build.git Fix up failover_host exceptions to preserve states 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 --- diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 9c124ad6a..c39f2763a 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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