From f266d40116293b5c89c44474171eb627502b272f Mon Sep 17 00:00:00 2001 From: Anton Arefiev Date: Fri, 13 May 2016 13:51:57 +0300 Subject: [PATCH] Fix update inventory for multiple providers DB call method get_all_by_resource_provider_uuid queries all Inventories and filters them by provider's uuid from ResourceProvider, but query list is not valid (contains inventories for all providers), the correct way to load ResourceProvider is to use query join. Replace joinedload with contains_eager to avoid redundant joins. As result last updated provider overwrites all provider's inventories with wrong data. Closes-Bug: #1572555 Change-Id: I49fb1bf63400280635c202dea8f870d727a91e81 --- nova/db/sqlalchemy/api_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py index e8bee347d..953499394 100644 --- a/nova/db/sqlalchemy/api_models.py +++ b/nova/db/sqlalchemy/api_models.py @@ -308,8 +308,8 @@ class Inventory(API_BASE): allocation_ratio = Column(Float, nullable=False) resource_provider = orm.relationship( "ResourceProvider", - primaryjoin=('and_(Inventory.resource_provider_id == ' - 'ResourceProvider.id)'), + primaryjoin=('Inventory.resource_provider_id == ' + 'ResourceProvider.id'), foreign_keys=resource_provider_id)