Description
===========
instance_group_members record also exist in database after delete vm
Steps to reproduce
==================
1:create affinity instance_group
2:create vm
3:delete vm
Actual result
=============
Database changed
MariaDB [nova_api]> select * from instance_group_member where group_id='3';
+---------------------+------------+-----+--------------------------------------+----------+
| created_at | updated_at | id | instance_uuid | group_id |
+---------------------+------------+-----+--------------------------------------+----------+
| 2018-02-12 09:14:42 | NULL | 106 | 3b9aa471-612f-4967-a405-574241e84aa0 | 3 |
| 2018-02-12 09:15:14 | NULL | 107 | e04244d9-2832-482a-9793-b5cc5b018de2 | 3 |
| 2018-02-22 03:05:40 | NULL | 108 | ff7a2194-9f38-4a7e-a67f-f0c53e409e9b | 3 |
| 2018-02-22 04:07:43 | NULL | 109 | 50000a55-8d0f-4592-ae0f-e9223c3f6a32 | 3 |
| 2018-02-22 08:36:44 | NULL | 110 | 4ef31c5c-d96f-4e24-ba86-75c5576ae4ed | 3 |
| 2018-02-22 09:36:39 | NULL | 111 | 0378c1bb-2d79-4b33-8115-77a75996af38 | 3 |
| 2018-02-23 00:40:05 | NULL | 112 | 08dac72d-8f04-4f7d-8b9a-60b0cf000951 | 3 |
+---------------------+------------+-----+--------------------------------------+----------+
7 rows in set (0.00 sec)
MariaDB [nova_api]> use nova;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [nova]> select * from instances where uuid='3b9aa471-612f-4967-a405-574241e84aa0';
+---------------------+---------------------+---------------------+-----+-------------+----------------------------------+----------------------------------+--------------------------------------+-----------+------------+--------------+----------+----------+-------------+----------+-----------+-------+------------+-------------+-----------+----------------+---------------------+---------------------+--------------+---------------------+-------------------+--------+---------+-------------+------------------+---------+--------------------------------------+--------------+------------------+--------------+--------------+--------------+------------+--------------------------+---------------------+----------+------------------+--------------------+-------------------+---------+--------------+-----------+-------------+---------+-----------+---------+--------------------+
| created_at | updated_at | deleted_at | id | internal_id | user_id | project_id | image_ref | kernel_id | ramdisk_id | launch_index | key_name | key_data | power_state | vm_state | memory_mb | vcpus | hostname | host | user_data | reservation_id | launched_at | terminated_at | display_name | display_description | availability_zone | locked | os_type | launched_on | instance_type_id | vm_mode | uuid | architecture | root_device_name | access_ip_v4 | access_ip_v6 | config_drive | task_state | default_ephemeral_device | default_swap_device | progress | auto_disk_config | shutdown_terminate | disable_terminate | root_gb | ephemeral_gb | cell_name | node | deleted | locked_by | cleaned | ephemeral_key_uuid |
+---------------------+---------------------+---------------------+-----+-------------+----------------------------------+----------------------------------+--------------------------------------+-----------+------------+--------------+----------+----------+-------------+----------+-----------+-------+------------+-------------+-----------+----------------+---------------------+---------------------+--------------+---------------------+-------------------+--------+---------+-------------+------------------+---------+--------------------------------------+--------------+------------------+--------------+--------------+--------------+------------+--------------------------+---------------------+----------+------------------+--------------------+-------------------+---------+--------------+-----------+-------------+---------+-----------+---------+--------------------+
| 2018-02-12 09:14:42 | 2018-02-13 00:58:48 | 2018-02-13 00:58:48 | 255 | NULL | 86019a90ad0b44609cca8b0eb9eee79b | 01f2572fd19743558be05561e09c3850 | 22164f51-c353-4f8a-a073-cbb2930bf25f | | | 0 | NULL | NULL | 0 | deleted | 2048 | 1 | test-tx001 | nail-5300-2 | NULL | r-j42bg7io | 2018-02-12 09:14:56 | 2018-02-13 00:58:48 | test_tx001 | NULL | test1 | 0 | NULL | nail-5300-2 | 14 | NULL | 3b9aa471-612f-4967-a405-574241e84aa0 | NULL | /dev/vda | NULL | NULL | | NULL | NULL | NULL | 0 | 0 | 0 | 0 | 10 | 0 | NULL | nail-5300-2 | 255 | NULL | 1 | NULL |
+---------------------+---------------------+---------------------+-----+-------------+----------------------------------+----------------------------------+--------------------------------------+-----------+------------+--------------+----------+----------+-------------+----------+-----------+-------+------------+-------------+-----------+----------------+---------------------+---------------------+--------------+---------------------+-------------------+--------+---------+-------------+------------------+---------+--------------------------------------+--------------+------------------+--------------+--------------+--------------+------------+--------------------------+---------------------+----------+------------------+--------------------+-------------------+---------+--------------+-----------+-------------+---------+-----------+---------+--------------------+
1 row in set (0.00 sec)
That looks fine to me, given we lazy-load the members field when calling it. So, I'm pretty sure the InstanceGroup. members shouldn't be saying that 3b9aa471- 612f-4967- a405-574241e84a a0 is in there.
Could you please verify that ?
Also, which Nova version are you using ?