summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Hesketh <josh@nitrotech.org>2013-11-19 12:42:51 +1100
committerJoshua Hesketh <josh@nitrotech.org>2014-01-17 16:05:18 +1100
commit6279478fbeea4a45dc9611a861fe68af910dd640 (patch)
tree0c13a6085a857cff84f89d756362581d94e71727
parente7b2e3a6c30e5a7d75440a881a4986bab37189bb (diff)
downloadnova-6279478fbeea4a45dc9611a861fe68af910dd640.tar.gz
Fix migration 147 downgrading with no aggregates
Add some extra bulletproofing to downgrading migration 147 where there may have been no aggregates. Change-Id: I6e4aabf4fff462e9ad53083621077ce0e0a80a43
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py b/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
index 0f62e39b98..422e35890c 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/147_no_service_zones.py
@@ -83,7 +83,7 @@ def downgrade(migrate_engine):
# Only need to update nova-compute availability_zones
if rec['binary'] != 'nova-compute':
continue
- result = select([aggregate_metadata.c.value],
+ query = select([aggregate_metadata.c.value],
from_obj=aggregate_metadata.join(
agg_hosts,
agg_hosts.c.aggregate_id == aggregate_metadata.c.aggregate_id
@@ -96,8 +96,12 @@ def downgrade(migrate_engine):
agg_hosts.c.host == rec['host']
)
- services.update().values(
- availability_zone=list(result.execute())[0][0]
- ).where(
- services.c.id == rec['id']
- )
+ result = list(query.execute())
+ # Check that there used to be an availability_zone. It is possible to
+ # have no aggregates.
+ if len(result) > 0:
+ services.update().values(
+ availability_zone=result[0][0]
+ ).where(
+ services.c.id == rec['id']
+ )