From 2dbd05452c4be3ea13f04571a8f821d228449197 Mon Sep 17 00:00:00 2001 From: Alex O'Rourke Date: Thu, 10 Mar 2016 13:33:20 -0800 Subject: [PATCH] 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 --- cinder/volume/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.45.2