KeyError: 'flavor' when nova boot

Bug #1781368 reported by zhaolihui on 2018-07-12
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

It maybe occur KeyError flavor when nova boot vm

# nova --debug boot vm --image image-id --flavor flavor-id --nic net-id=id

It will show vm's information, but it return Error like that:

DEBUG (session:419) RESP: [202] Content-Length: 462 Location: controller:8774/v2.1/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748 Content-Type: application/json Openstack-Api-Version: compute 2.60 X-Openstack-Nova-Api-Version: 2.60 Vary: OpenStack-API-Version, X-OpenStack-Nova-API-Version X-Openstack-Request-Id: req-07b4cdd4-2a22-4791-a6b1-7ea4b7628370 X-Compute-Request-Id: req-07b4cdd4-2a22-4791-a6b1-7ea4b7628370 Date: Thu, 12 Jul 2018 06:34:49 GMT
RESP BODY: {"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": "MANUAL", "id": "c095438d-7a8a-4b00-a53d-882a1f988748", "links": [{"href": "controller:8774/v2.1/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748", "rel": "self"}, {"href": "controller:8774/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748", "rel": "bookmark"}], "adminPass": "2oHes4hprNs8"}}

DEBUG (session:722) POST call to compute for controller:8774/v2.1/7fcede66893a4d179f3d37958a06d801/servers used request id req-07b4cdd4-2a22-4791-a6b1-7ea4b7628370
DEBUG (session:372) REQ: curl -g -i -X GET controller:8774/v2.1/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748 -H "OpenStack-API-Version: compute 2.60" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-OpenStack-Nova-API-Version: 2.60" -H "X-Auth-Token: {SHA1}4dc236317ec12f176dd4e844738ec85cee5c12df"
DEBUG (connectionpool:395) controller:8774 "GET /v2.1/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748 HTTP/1.1" 404 111
DEBUG (session:419) RESP: [404] Openstack-Api-Version: compute 2.60 X-Openstack-Nova-Api-Version: 2.60 Vary: OpenStack-API-Version, X-OpenStack-Nova-API-Version Content-Type: application/json; charset=UTF-8 Content-Length: 111 X-Openstack-Request-Id: req-10da61f5-3624-4b56-8c7b-849eb163b0fc X-Compute-Request-Id: req-10da61f5-3624-4b56-8c7b-849eb163b0fc Date: Thu, 12 Jul 2018 06:34:49 GMT
RESP BODY: {"itemNotFound": {"message": "Instance c095438d-7a8a-4b00-a53d-882a1f988748 could not be found.", "code": 404}}

DEBUG (session:722) GET call to compute for controller:8774/v2.1/7fcede66893a4d179f3d37958a06d801/servers/c095438d-7a8a-4b00-a53d-882a1f988748 used request id req-10da61f5-3624-4b56-8c7b-849eb163b0fc
DEBUG (shell:793) 'flavor'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/novaclient/", line 791, in main
  File "/usr/lib/python2.7/site-packages/novaclient/", line 713, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/", line 889, in do_boot
    _print_server(cs, args, server)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/", line 2240, in _print_server
    del info['flavor']
KeyError: 'flavor'
ERROR (KeyError): 'flavor'


zhaolihui (zhaolh) on 2018-07-12
Changed in nova:
assignee: nobody → zhaolihui (zhaolh)
melanie witt (melwitt) wrote :

The KeyError is coming from python-novaclient, not nova, so I'm going to mark this Invalid for nova and add python-novaclient to this bug.

Changed in nova:
status: New → Invalid
Changed in python-novaclient:
assignee: nobody → zhaolihui (zhaolh)
status: New → In Progress
zhaolihui (zhaolh) on 2018-07-13
Changed in nova:
assignee: zhaolihui (zhaolh) → nobody
no longer affects: nova
Changed in python-novaclient:
assignee: zhaolihui (zhaolh) → Takashi NATSUME (natsume-takashi)

Submitter: Zuul
Branch: master

commit b13ba0138f6ee2e10ce3b4b95aee37c6cebd1f20
Author: zhaolihui <email address hidden>
Date: Thu Jul 12 11:12:54 2018 +0000

    Fix flavor keyerror when nova boot vm

    When creating a server (the 'nova boot' command),
    it calls 'POST /servers' API.

    The response does not have 'addresses' and 'flavor' attributes.
    When accessing 'networks' attribute in the '_print_server' function,
    it calls 'GET /servers/{server_id}' and get the 'addresses' and
    'flavor' attributes.

    If 'GET /servers/{server_id}' fails, the server object does not have
    the 'flavor' attribute, then KeyError is raised when accessing it.

    Fix the issue by making it raise a CommandError
    when the 'GET /servers/{server_id}' fails.

    Co-Authored-By: Takashi Natsume <email address hidden>
    Change-Id: I3ef096c61b0e05a637ab0c4a1027338fa87e4f09
    Closes-Bug: #1781368

Changed in python-novaclient:
status: In Progress → Fix Released

This issue was fixed in the openstack/python-novaclient 12.0.0 release.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers