Nova flavor-show should not get deleted flavor

Bug #1168260 reported by Qing Xin Meng
72
This bug affects 14 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Qing Xin Meng

Bug Description

Issue #1
A deleted flavor still could be shown

Issue #2
Create another flavor with some different parameters, and the id is same with the deleted flavor id, after creation, run the command "nova flavor-show id", it still shows the information of the deleted flavor.

Recreate these issues.
===
===
[root@localhost ˜]# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-- ---------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | I s_Public | extra_specs |
+----+-----------+-----------+------+-----------+------+-------+-------------+-- ---------+-------------+
| 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | T rue | {} |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | T rue | {} |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | T rue | {} |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | T rue | {} |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | T rue | {} |
+----+-----------+-----------+------+-----------+------+-------+-------------+-- ---------+-------------+
[root@localhost ˜]# nova flavor-create flavor6 6 128 0 1
+----+---------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+---------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 6 | flavor6 | 128 | 0 | 0 | | 1 | 1.0 | True | {} |
+----+---------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
[root@localhost ˜]# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} |
| 6 | flavor6 | 128 | 0 | 0 | | 1 | 1.0 | True | {} |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
[root@localhost ˜]# nova flavor-delete 6
[root@localhost ˜]# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
[root@localhost ˜]# nova flavor-show 6
+----------------------------+---------+
| Property | Value |
+----------------------------+---------+
| name | flavor6 |
| ram | 128 |
| OS-FLV-DISABLED:disabled | False |
| vcpus | 1 |
| extra_specs | {} |
| swap | |
| os-flavor-access:is_public | True |
| rxtx_factor | 1.0 |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 0 |
| id | 6 |
+----------------------------+---------+
[root@localhost ˜]# nova flavor-create flavor_t 6 256 1 1
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 6 | flavor_t | 256 | 1 | 0 | | 1 | 1.0 | True | {} |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
[root@localhost ˜]# nova flavor-show 6
+----------------------------+---------+
| Property | Value |
+----------------------------+---------+
| name | flavor6 |
| ram | 128 |
| OS-FLV-DISABLED:disabled | False |
| vcpus | 1 |
| extra_specs | {} |
| swap | |
| os-flavor-access:is_public | True |
| rxtx_factor | 1.0 |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 0 |
| id | 6 |
+----------------------------+---------+
[root@localhost ˜]#
===

Changed in nova:
assignee: nobody → Satyanarayana Patibandla (satya-patibandla-i)
status: New → Confirmed
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

Fixed this issue when i changed code from:

def get_instance_type_by_flavor_id(flavorid, ctxt=None, read_deleted="yes"):

to

def get_instance_type_by_flavor_id(flavorid, ctxt=None, read_deleted="no"):

What do you think this?

Revision history for this message
Tiantian Gao (gtt116) wrote :

I think it's better to specify param read_deleted='False' when invoke instance_types.get_instance_type_by_flavor_id() in show() method (nova.api.openstack.compute.flavors:Controller.show).

Revision history for this message
Satyanarayana Patibandla (satya-patibandla-i) wrote :

I agree with you. The function get_instance_type_by_flavor_id is being called in many places. if we change the defination it will have impact on many other places. so it is better to chanege it in show() method.

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

Yes, you are right, it's improper to change function get_instance_type_by_flavor_id.

Revision history for this message
Kevin L. Mitchell (klmitch) wrote :

I believe one of the reasons we want to allow "show" on deleted flavor IDs has to do with instances that are still using those flavor IDs; we wanted the "nova" tool to be able to query the details about the flavor ID in question.

Revision history for this message
Ben Nemec (bnemec) wrote :

I've hit this problem on resizes as well, and there it definitely needs to be fixed because it results in an attempt to resize to a deleted flavor, which naturally fails.

Revision history for this message
Ben Nemec (bnemec) wrote :

Actually, it appears the situation I hit has already been fixed in a different way. On a Folsom install I was getting failed resizes due to a deleted flavor with the same id, and it was related to this bug. When I checked the code it looked like it was still an issue, but the current Nova seems to make sure the instance_type id is unique so that's no longer a problem.

Revision history for this message
Satyanarayana Patibandla (satya-patibandla-i) wrote :

The show() method should have intelligence while displaying the flavor details.

If flavor details are deleted then it has to show the deleted flavor details.

If flavor details are deleted and recreated with the same id then it should
show the newly created flavor details.

Still I need to check the feasibility of this approach. Please let me know if you
have any concerns with this approach.

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

For the similar resize operation issue, it is just exist on Folsom, for Grizzly it's fixed, so the resize operation will not used deleted flavor.
===
https://review.openstack.org/#/c/15344/
https://github.com/openstack/nova/commit/25743e4fc3dc845afacebe7f790c11cf35fbadea
===

For this flavor bug, both Folsom and Grizzly is exist.

In the table 'instance_type' field 'id' is unique, but the field 'flavorid' is not unique, and for the 'nova flavor-xx' operation, only the flavorid can be used, so use a deleted flavorid and name repeatedly is out of control.

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

The usage of nova flavor-show:
===
[root@localhost ~]# nova help flavor-show
usage: nova flavor-show <flavor>

Show details about the given flavor.

Positional arguments:
  <flavor> Name or ID of flavor
[root@localhost ~]#
===
So, both the flavorid and flavorname is supported.

But after my verification, i found the deleted flavor will not show when use the 'flavorname' as the argument in 'nova flavor-show'.
I think the action should be same 'flavorid' with 'flavorname', so 'nova flavor-show flavorid' should not show the deleted flavor infomation.

Satyanarayana, what do you think of this? do you have any progress?

Revision history for this message
Satyanarayana Patibandla (satya-patibandla-i) wrote :

Qing, Your comment and Kevin's comments both are valid. How about showing both the flavor details ( deleted flavor information and newly created flavor with same id) in the flavor-show output?

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

As the current case: the 'nova flavor-show flavorname' will not show the deleted flavor information.
So, i think the fix will do: the 'nova flavor-show flavorid' will not show the deleted flavor information also.

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

Satyanarayana, any progress? and have you submitted a review?
if not, I will submit a review today or tommorow.

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/27647

Changed in nova:
assignee: Satyanarayana Patibandla (satya-patibandla-i) → Qing Xin Meng (mengqxqx)
Revision history for this message
Litty Preeth (littypreethkr) wrote :

Hi Qing,

Do you have any different approach for this? Actually Kevin's comment is valid. So changing the show method to not return any deleted flavor is not good. So I guess the solution is what Satyanarayana proposed:
"If flavor details are deleted then it has to show the deleted flavor details. If flavor details are deleted and recreated with the same id then it should show the newly created flavor details."

If we need to fix this without touching db.instance_type_get_by_flavor_id then we will need to add a new db api for returning all the flavors by id and then filter out in show or have a new db api which preferably returns the non-deleted flavor.

But looking at the other parts where db.instance_type_get_by_flavor_id is used (in the flavor_access APIs) it seems safe enough to change existing db.instance_type_get_by_flavor_id to return non-deleted flavor incase the query fetches more than one.

Being said that, I agree to the fact that "nova falvor-show id" should return only the non-deleted flavors to be consistent with "nova flavor-show name" and all the other show methods. But in that case the flavor-delete should not be allowed if instances created from that flavor are existing.

Regards,
Litty

Revision history for this message
Qing Xin Meng (mengqxqx) wrote :

Litty,

I think this bug has already fixed.

Issue 1. A deleted flavor still could be shown
This is worked as design.
---
- nova flavor-show flavor-id
If the flavor-id is used in nova command, will show the deleted flavor.

- nova flavor-show flavor-name
If the flavor-name is used in nova-show, Will NOT show the deleted flavor.
---

Issue 2. Show the deleted flavor info
The following code review already fixed this.
https://review.openstack.org/#/c/22477/
So, now If one flavor was deleted and recreated new flavor with the same id, it will show the newly created flavor details.

Thanks!

Revision history for this message
Ben Nemec (bnemec) wrote :

Marking this fixed based on Qing Xin's comment.

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
lafada (lafada) wrote :
Download full text (3.5 KiB)

I am still facing same problem :(.

I have havana-2 code(https://github.com/openstack/nova/tree/2013.2.b2).

1. Created new flavor.
[root@localhost]# nova flavor-create test.flavor 99 512 5 2
+----+------------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+------------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 99 | test.flavor | 512 | 5 | 0 | | 2 | 1.0 | True | {} |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+

2. Check flavor.
[root@localhost]# nova flavor-show 99
+----------------------------+----------+
| Property | Value |
+----------------------------+----------+
| name | test.flavor |
| ram | 512 |
| OS-FLV-DISABLED:disabled | False |
| vcpus | 2 |
| extra_specs | {} |
| swap | |
| os-flavor-access:is_public | True |
| rxtx_factor | 1.0 |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 5 |
| id | 99 |
+----------------------------+----------+

3. Delete flavor and check.
[root@localhost]# nova flavor-delete 99
[root@localhost]# nova flavor-show 99
+----------------------------+----------+
| Property | Value |
+----------------------------+----------+
| name | test.flavor |
| ram | 512 |
| OS-FLV-DISABLED:disabled | False |
| vcpus | 2 |
| extra_specs | {} |
| swap | |
| os-flavor-access:is_public | True |
| rxtx_factor | 1.0 |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 5 |
| id | 99 |
+----------------------------+----------+

4. Create another flavor with same id (99).
[root@localhost]# nova flavor-create test.flavor.new 99 512 5 2
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 99 | test.flavor.new | 512 | 5 | 0 | | 2 | 1.0 | True | {} |
+----+--------------+-----------+------+-----------+------+-------+-------------+-----------+-------------+

5. Check flavor for id (99).
[root@localhost]# nova flavor-show 99
+----------------------------+----------+
| Property | Value |
+----------------------------+----------+
| name | test.flavor |
| ram | 512 |
| OS-FLV-DISABLED:disabled | False |
| vcpus | 2 |
| extra_specs ...

Read more...

Revision history for this message
Sushil Kumar (sushil-kumar2) wrote :

This bug is still there ...
and its not yet fixed.

still flavor-show shows the delete flavors.

Revision history for this message
Sushil Kumar (sushil-kumar2) wrote :

still flavor-show shows the deleted flavors.

Revision history for this message
Fu Guang Ping (fuguangping) wrote :

It's easy to mislead end-user who is always working on dashboard if we show the deleted flavor by default. Our clients have complained about it many times. I think it may be better to pass an option in the `show` method or just response a delete status field which can be used as a filter to the front.

Revision history for this message
larkinscarvalho@gmail.com (larkinscarvalho) wrote :

This bug still exists. It is OK to show the deleted flavor.
But there should be some flag associated with the deleted flavor.

Any plans to fix this bug?

Revision history for this message
Michal Ptacek (michalx-ptacek) wrote :

I can also see deleted flavor, in my case I wrongly passed arguments of flavor-create:

nova flavor-create auto nodepool-14-35-24 14336 35 24

which created flavor with id "nodepool-14-35-24" and name "auto"
when deleted via (nova flavor-delete nodepool-14-35-24 | or nova flavor-delete auto)
I can still see some remnants of deleted flavor.

nova flavor-show nodepool-14-35-24
+----------------------------+-------------------+
| Property | Value |
+----------------------------+-------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 35 |
| extra_specs | N/A |
| id | nodepool-14-35-24 |
| name | auto |
| os-flavor-access:is_public | True |
| ram | 14336 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 24 |
+----------------------------+-------------------+

unfortunately when I create a proper flavor
nova flavor-create nodepool-14-35-24 auto 14336 35 24

I can't modify it via "nova flavor-key nodepool-14-35-24 ...."
ERROR (NotFound): Flavor nodepool-14-35-24 could not be found
probably it's preferring flavor-id of deleted flavor ....

I can modify using flavor id, but this mess is confusing me and I would like to clean it somehow first to avoid potentially further problems,

any suggestions for cleaning the mess ?
thanks

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

Remote bug watches

Bug watches keep track of this bug in other bug trackers.