yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #04619
[Bug 1211307] Re: instance_group_delete() filters related entities by group UUID rather than by ID
** Changed in: nova
Status: Fix Committed => Fix Released
** Changed in: nova
Milestone: None => havana-3
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1211307
Title:
instance_group_delete() filters related entities by group UUID rather
than by ID
Status in OpenStack Compute (Nova):
Fix Released
Bug description:
Table 'instance_groups' has two columns to unambiguously identify the specific row:
1) id (Integer, primary_key=True, autoincrement=True)
2) uuid (String)
The former is used internally to bind related entities by FKs
(InstanceGroupMember, InstanceGroupPolicy and InstanceGroupMetadata),
and the latter is accepted by public DB API methods (this must be a
miss in the DB schema design, because uuid could be easily used for
both use cases).
Having two 'id' columns is both misleading and error-prone. E. g.
instance_group_delete() deletes the instance group (and all related
entities) given its UUID value:
def instance_group_delete(context, group_uuid):
"""Delete an group."""
session = get_session()
with session.begin():
count = _instance_group_get_query(context,
models.InstanceGroup,
models.InstanceGroup.uuid,
group_uuid,
session=session).soft_delete()
if count == 0:
raise exception.InstanceGroupNotFound(group_uuid=group_uuid)
# Delete policies, metadata and members
instance_models = [models.InstanceGroupPolicy,
models.InstanceGroupMetadata,
models.InstanceGroupMember]
for model in instance_models:
model_query(context, model, session=session).\
filter_by(group_id=group_uuid).\
soft_delete()
Related entities are filtered by 'group_id' column, but 'group_uuid'
value is passed. Despite that these two columns are of different
types, this statement is executed successfully on MySQL and SQLite
(though WHERE clause never evaluates to True, so related entities
aren't actually deleted), but fails on PostgreSQL, which is more
strict when checking data types of values.
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1211307/+subscriptions