yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #12608
[Bug 1294756] Re: missing test for None in sqlalchemy query filter
** Changed in: nova
Status: Fix Committed => Fix Released
--
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/1294756
Title:
missing test for None in sqlalchemy query filter
Status in OpenStack Compute (Nova):
Fix Released
Bug description:
In db.sqlalchemy.api.instance_get_all_by_filters() there is code that
looks like this:
if not filters.pop('soft_deleted', False):
query_prefix = query_prefix.\
filter(models.Instance.vm_state != vm_states.SOFT_DELETED)
In sqlalchemy a comparison against a non-null value will not match null values, so the above filter will not return objects where vm_state is NULL.
The problem is that in the Instance object the "vm_state" field is
declared as nullable. In many cases "vm_state" will in fact have a
value, but in get_test_instance() in test/utils.py the value of
"vm_state" is not specified.
Given the above, it seems that either we need to configure
"models.Instance.vm_state" as not nullable (and deal with the
fallout), or else we need to update instance_get_all_by_filters() to
explicitly check for None--something like this perhaps:
if not filters.pop('soft_deleted', False):
query_prefix = query_prefix.\
filter(or_(models.Instance.vm_state != vm_states.SOFT_DELETED,
models.Instance.vm_state == None))
If we want to fix the query, I'll happily submit the updated code.
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1294756/+subscriptions
References