Re: [openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-31 Thread Vishvananda Ishaya

On Mar 27, 2014, at 4:38 PM, Chris Friesen chris.frie...@windriver.com wrote:

 On 03/27/2014 04:47 PM, Chris Friesen wrote:
 
 Interestingly, unit test
 nova.tests.api.openstack.compute.contrib.test_server_groups.ServerGroupTest.test_display_members
 passes just fine, and it seems to be running the same sqlalchemy code.
 
 Is this a case where sqlite behaves differently from mysql?
 
 Sorry to keep replying to myself, but this might actually hit us other places.
 
 Down in db/sqlalchemy/api.py we end up calling
 
 
 query = query.filter(column_attr.op(db_regexp_op)('None’))

Sqlalchemy handles mapping None to NULL in many cases, so it appears that the 
problem is that we are passing
None as a string here?

Vish

 
 
 When using mysql, it looks like a regexp comparison of the string 'None' 
 against a NULL field fails to match.
 
 Since sqlite doesn't have its own regexp function we provide one in 
 openstack/common/db/sqlalchemy/session.py.  In the buggy case we end up 
 calling it as regexp('None', None), where the types are unicode and 
 NoneType.  However, we end up converting the second arg to text type before 
 calling reg.search() on it, so it matches.
 
 Chris
 
 ___
 OpenStack-dev mailing list
 OpenStack-dev@lists.openstack.org
 http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-31 Thread Chris Friesen

On 03/31/2014 03:56 PM, Vishvananda Ishaya wrote:


On Mar 27, 2014, at 4:38 PM, Chris Friesen chris.frie...@windriver.com wrote:


On 03/27/2014 04:47 PM, Chris Friesen wrote:


Interestingly, unit test
nova.tests.api.openstack.compute.contrib.test_server_groups.ServerGroupTest.test_display_members
passes just fine, and it seems to be running the same sqlalchemy code.

Is this a case where sqlite behaves differently from mysql?


Sorry to keep replying to myself, but this might actually hit us other places.

Down in db/sqlalchemy/api.py we end up calling


query = query.filter(column_attr.op(db_regexp_op)('None’))


Sqlalchemy handles mapping None to NULL in many cases, so it appears that the 
problem is that we are passing
None as a string here?


I think fundamentally it makes no sense to try and regex match a NULL 
database field.  So in instance_get_all_by_filters() if we want to test 
for None it should be done separate from the regex filter.


Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


[openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-27 Thread Chris Friesen
I've filed this as a bug (https://bugs.launchpad.net/nova/+bug/1298494) 
but I thought I'd post it here as well to make sure it got visibility.


If I create a server group, then boot a server as part of the group, 
then run nova server-group-list it doesn't show the server as being a 
member of the group.


The problem seems to be with the filter passed in to 
instance_obj.InstanceList.get_by_filters() in 
api.openstack.compute.contrib.server_groups.ServerGroupController._format_server_group(). 



I traced it down as far as 
db.sqlalchemy.api.instance_get_all_by_filters(). Before this line the 
query output looks good:


query_prefix = regex_filter(query_prefix, models.Instance, filters)

but after that line there are no instances left in the filter results.


If I change the filter to use

'deleted': False

instead of

'deleted_at': None

then it works as expected.


The leads to a couple of questions:

1) There is a column deleted_at in the database table, why can't we 
filter on it?

2) How did this get submitted when it doesn't work?

Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-27 Thread Chris Friesen

On 03/27/2014 03:57 PM, Chris Friesen wrote:


If I change the filter to use

'deleted': False

instead of

'deleted_at': None

then it works as expected.


The leads to a couple of questions:

1) There is a column deleted_at in the database table, why can't we
filter on it?


I wonder if maybe the problem is that you can't pattern match against 
None.


Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-27 Thread Chris Friesen

On 03/27/2014 03:57 PM, Chris Friesen wrote:


The leads to a couple of questions:

1) There is a column deleted_at in the database table, why can't we
filter on it?
2) How did this get submitted when it doesn't work?


I've updated to the current codebase in devstack and I'm still seeing 
the problem.


Interestingly, unit test 
nova.tests.api.openstack.compute.contrib.test_server_groups.ServerGroupTest.test_display_members 
passes just fine, and it seems to be running the same sqlalchemy code.


Is this a case where sqlite behaves differently from mysql?

Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [nova] [bug] nova server-group-list doesn't show any members

2014-03-27 Thread Chris Friesen

On 03/27/2014 04:47 PM, Chris Friesen wrote:


Interestingly, unit test
nova.tests.api.openstack.compute.contrib.test_server_groups.ServerGroupTest.test_display_members
passes just fine, and it seems to be running the same sqlalchemy code.

Is this a case where sqlite behaves differently from mysql?


Sorry to keep replying to myself, but this might actually hit us other 
places.


Down in db/sqlalchemy/api.py we end up calling


query = query.filter(column_attr.op(db_regexp_op)('None'))


When using mysql, it looks like a regexp comparison of the string 'None' 
against a NULL field fails to match.


Since sqlite doesn't have its own regexp function we provide one in 
openstack/common/db/sqlalchemy/session.py.  In the buggy case we end up 
calling it as regexp('None', None), where the types are unicode and 
NoneType.  However, we end up converting the second arg to text type 
before calling reg.search() on it, so it matches.


Chris

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev