nova flavor-delete fails with InstanceTypeNotFoundByName API error

Bug #1048678 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Vish Ishaya

Bug Description

Problem Description:

When attempting "nova flavor-delete" sometimes an API error occurs, where it seems that the ID passed as a nova CLI argument is mapped to the wrong flavor name, resulting in a "could not be found" 404 error, even though the selected ID is present in the "nova flavor-list" output:

```
[root@heatlt heat]# nova flavor-list
+----+------------+-----------+------+-----------+------+-------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor |
+----+------------+-----------+------+-----------+------+-------+-------------+
| 1 | t1.micro | 256 | 0 | 10 | | 1 | 1.0 |
| 8 | m2.2xlarge | 2048 | 0 | 10 | | 2 | 1.0 |
| 9 | m2.4xlarge | 2048 | 0 | 10 | | 2 | 1.0 |
+----+------------+-----------+------+-----------+------+-------+-------------+

[root@heatlt heat]# nova --debug flavor-delete 1
connect: (127.0.0.1, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: 127.0.0.1:5000\r\nContent-Length: 106\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "verybadpass"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Vary: X-Auth-Token
header: Date: Mon, 10 Sep 2012 14:15:08 GMT
header: Transfer-Encoding: chunked
connect: (localhost, 8774)
send: u'DELETE /v1.1/fd7795f68eab47d0906d305e470ab155/flavors/1 HTTP/1.1\r\nHost: localhost:8774\r\nx-auth-project-id: admin\r\nx-auth-token: 1f98c1b6366146ea8a8b70ba1a4cfd31\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Content-Length: 78
header: Content-Type: application/json; charset=UTF-8
header: X-Compute-Request-Id: req-ece516fa-cebd-491b-ac66-c24f75bc63c5
header: Date: Mon, 10 Sep 2012 14:15:09 GMT
DEBUG (shell:416) The resource could not be found. (HTTP 404)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/novaclient/shell.py", line 413, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.7/site-packages/novaclient/shell.py", line 364, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/site-packages/novaclient/v1_1/shell.py", line 311, in do_flavor_delete
    cs.flavors.delete(args.id)
  File "/usr/lib/python2.7/site-packages/novaclient/v1_1/flavors.py", line 59, in delete
    self._delete("/flavors/%s" % base.getid(flavor))
  File "/usr/lib/python2.7/site-packages/novaclient/base.py", line 166, in _delete
    resp, body = self.api.client.delete(url)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 145, in delete
    return self._cs_request(url, 'DELETE', **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 124, in _cs_request
    **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 107, in request
    raise exceptions.from_response(resp, body)
NotFound: The resource could not be found. (HTTP 404)
ERROR: The resource could not be found. (HTTP 404)
```

There is a backtrace in the nova API log, which seems to suggest the ID (t1.micro) is being mapped to the wrong name ( m1.tiny), full backtrace attached.

```
2012-09-10 15:15:09 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/contrib/flavormanage.py", line 49, in _delete
2012-09-10 15:15:09 TRACE nova.api.openstack instance_types.destroy(flavor['name'])
2012-09-10 15:15:09 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/compute/instance_types.py", line 87, in destroy
2012-09-10 15:15:09 TRACE nova.api.openstack raise exception.InstanceTypeNotFoundByName(instance_type_name=name)
2012-09-10 15:15:09 TRACE nova.api.openstack InstanceTypeNotFoundByName: Instance type with name m1.tiny could not be found.
2012-09-10 15:15:09 TRACE nova.api.openstack
2012-09-10 15:15:09 INFO nova.api.openstack [req-ece516fa-cebd-491b-ac66-c24f75bc63c5 0c8a0190783648159f3e4b4fd2aaca03 fd7795f68eab47d0906d305e470ab155] http://localhost:8774/v1.1/fd7795f68eab47d0906d305e470ab155/flavors/1 returned with HTTP 404
```

Test environment : Fedora 17, package versions as follows:

$ rpm -qa | grep nova
openstack-nova-volume-2012.1.1-15.fc17.noarch
python-nova-2012.1.1-15.fc17.noarch
openstack-nova-cert-2012.1.1-15.fc17.noarch
openstack-nova-scheduler-2012.1.1-15.fc17.noarch
python-novaclient-2012.1-2.fc17.noarch
openstack-nova-compute-2012.1.1-15.fc17.noarch
openstack-nova-api-2012.1.1-15.fc17.noarch
openstack-nova-2012.1.1-15.fc17.noarch
openstack-nova-objectstore-2012.1.1-15.fc17.noarch
openstack-nova-console-2012.1.1-15.fc17.noarch
openstack-nova-common-2012.1.1-15.fc17.noarch
openstack-nova-network-2012.1.1-15.fc17.noarch

Reproducer:

Running the heat-api "tools/nova_create_flavors.sh" script multiple times will reliably trigger this bug.

This script deletes all current flavors, and creates a predefined set of flavors. It will work once, then on the second run it nearly always errors on one flavor-delete. Copy of this script is attached below.

Revision history for this message
Steven Hardy (shardy) wrote :
Revision history for this message
Steven Hardy (shardy) wrote :

Script repoducer (from https://github.com/heat-api/heat tools)

Run this multiple times and the error described above occurs.

Changed in nova:
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → Vish Ishaya (vishvananda)
milestone: none → folsom-rc1
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/12729

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

Reviewed: https://review.openstack.org/12729
Committed: http://github.com/openstack/nova/commit/d741328543ad6059bef56adb59f4c94781eaedcd
Submitter: Jenkins
Branch: master

commit d741328543ad6059bef56adb59f4c94781eaedcd
Author: Vishvananda Ishaya <email address hidden>
Date: Mon Sep 10 12:15:02 2012 -0700

    Fix flavor deletion when there is a deleted flavor

    If there is a deleted flavor with the same ID as an undeleted flavor,
    the flavormanage delete code attempts to delete it again, which fails.
    This patch makes sure to pass read_deleted='no' when the flavor is
    retrieved for deletion so we get the undeleted flavor. Includes a
    failing test to make sure the value is passed properly.

    Fixes bug 1048678

    Change-Id: If6a20de2526b7ba90ada4a40317a98f79b2141dc

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-rc1 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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