"nova server-group-list" doesn't show members of the group

Bug #1298494 reported by Chris Friesen
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Chris Friesen
Icehouse
Fix Released
High
Chuck Short

Bug Description

With current devstack I ensured I had "GroupAntiAffinityFilter" in scheduler_default_filters in /etc/nova/nova.conf, restarted nova-scheduler, then ran:

nova server-group-create --policy anti-affinity antiaffinitygroup

nova server-group-list
+--------------------------------------+-------------------+--------------------+---------+----------+
| Id | Name | Policies | Members | Metadata |
+--------------------------------------+-------------------+--------------------+---------+----------+
| 5d639349-1b77-43df-b13f-ed586e73b3ac | antiaffinitygroup | [u'anti-affinity'] | [] | {} |
+--------------------------------------+-------------------+--------------------+---------+----------+

nova boot --flavor=1 --image=cirros-0.3.1-x86_64-uec --hint group=5d639349-1b77-43df-b13f-ed586e73b3ac cirros0

nova list
+--------------------------------------+---------+--------+------------+-------------+--------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+--------------------+
| a7a3ec40-85d9-4b72-a522-d1c0684f3ada | cirros0 | ACTIVE | - | Running | private=10.4.128.2 |
+--------------------------------------+---------+--------+------------+-------------+--------------------+

Then I tried listing the groups, and it didn't print the newly-booted instance as a member:

nova server-group-list
+--------------------------------------+-------------------+--------------------+---------+----------+
| Id | Name | Policies | Members | Metadata |
+--------------------------------------+-------------------+--------------------+---------+----------+
| 5d639349-1b77-43df-b13f-ed586e73b3ac | antiaffinitygroup | [u'anti-affinity'] | [] | {} |
+--------------------------------------+-------------------+--------------------+---------+----------+

Rerunning the nova command with --debug we see that the problem is in nova, not novaclient:

RESP BODY: {"server_groups": [{"members": [], "metadata": {}, "id": "5d639349-1b77-43df-b13f-ed586e73b3ac", "policies": ["anti-affinity"], "name": "antiaffinitygroup"}]}

Looking at the database, we see that the instance is actually tracked as a member of the list (along with two other instances that haven't been marked as deleted yet, which is also a bug I think).

mysql> select * from instance_group_member;
+---------------------+------------+------------+---------+----+--------------------------------------+----------+
| created_at | updated_at | deleted_at | deleted | id | instance_id | group_id |
+---------------------+------------+------------+---------+----+--------------------------------------+----------+
| 2014-03-26 20:19:14 | NULL | NULL | 0 | 1 | d289502b-57fc-46f6-b39d-66a1db3a9ebc | 1 |
| 2014-03-26 20:25:04 | NULL | NULL | 0 | 2 | e07f1f15-4e93-4845-9203-bf928c196a78 | 1 |
| 2014-03-26 20:35:11 | NULL | NULL | 0 | 3 | a7a3ec40-85d9-4b72-a522-d1c0684f3ada | 1 |
+---------------------+------------+------------+---------+----+--------------------------------------+----------+
3 rows in set (0.00 sec)

Chris Friesen (cbf123)
summary: - "nova instance-group-list" doesn't show members of the group
+ "nova server-group-list" doesn't show members of the group
Revision history for this message
Chris Friesen (cbf123) wrote :

I did some tracing down in 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.

Revision history for this message
Chris Friesen (cbf123) wrote :

Looks like the problem is with the filter, it should be using

filters = {'uuid': group.members, 'deleted': False}

instead of

filters = {'uuid': group.members, 'deleted_at': None}

Changed in nova:
assignee: nobody → Chris Friesen (cbf123)
Revision history for this message
Chris Friesen (cbf123) wrote :

Just to make things interesting, this passes in the unit tests using sqlite but fails with mysql. Opening bug 1298690 to cover that issue.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/83625

Changed in nova:
status: New → In Progress
tags: added: icehouse-rc-potential
Changed in nova:
importance: Undecided → High
Thierry Carrez (ttx)
tags: added: icehouse-backport-potential
removed: icehouse-rc-potential
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/83625
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8ce30b6ac7ea8d2e036a621a9904b35cb1563672
Submitter: Jenkins
Branch: master

commit 8ce30b6ac7ea8d2e036a621a9904b35cb1563672
Author: Chris Friesen <email address hidden>
Date: Thu Mar 27 16:49:31 2014 -0600

    Fix display of server group members

    The previous code was failing to display the members of server
    groups because it was filtering them all out.

    Interestingly, the previous code passes the unit tests due to a
    bug where we treat regex comparisons differently when using mysql
    vs sqlite (tracked under bug 1298690).

    Change-Id: I7be9c180f4284dd18cd02e510e77e3c1e3fc9925
    Closes-bug: 1298494

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to nova (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/89657

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to nova (stable/icehouse)

Reviewed: https://review.openstack.org/89657
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=40ae1eefe42f093631e2988814e60f45defdb3c3
Submitter: Jenkins
Branch: stable/icehouse

commit 40ae1eefe42f093631e2988814e60f45defdb3c3
Author: Chris Friesen <email address hidden>
Date: Thu Mar 27 16:49:31 2014 -0600

    Fix display of server group members

    The previous code was failing to display the members of server
    groups because it was filtering them all out.

    Interestingly, the previous code passes the unit tests due to a
    bug where we treat regex comparisons differently when using mysql
    vs sqlite (tracked under bug 1298690).

    Change-Id: I7be9c180f4284dd18cd02e510e77e3c1e3fc9925
    Closes-bug: 1298494
    (cherry picked from commit 8ce30b6ac7ea8d2e036a621a9904b35cb1563672)

tags: added: in-stable-icehouse
Alan Pevec (apevec)
tags: removed: icehouse-backport-potential in-stable-icehouse
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers