Failed to get flavors(raise 500) with a domain scope token(without project_id).

Bug #1733746 reported by Yikun Jiang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Yikun Jiang
Pike
Fix Committed
Low
Matt Riedemann

Bug Description

Description
===========
Failed to get flavors(raise a 500 error) with a domain scope
or unscope token(without project_id).

https://docs.openstack.org/keystone/pike/admin/identity-tokens.html#domain-scoped-tokens

Steps to reproduce
==================

1. Get a unscope token or domain token.
TOKEN=`curl -i -X POST http://10.76.6.31/identity/v3/auth/tokens -H "Accept: application/json" -H "Content-Type: application/json" -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"domain":{"name":"default"},"name":"admin","password":"xxx"}}}}}' | grep X-Subject-Token | awk '{ print $2 }’`

2. Get flavors.
curl -g -i -X GET http://10.76.6.31/compute/v2.1/flavors/detail -H "OpenStack-API-Version: compute 2.53" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-OpenStack-Nova-API-Version: 2.53" -H "X-Auth-Token: $TOKEN"

Expected result
===============
Get flavors back.

Actual result
=============
HTTP/1.1 500 Internal Server Error
Date: Fri, 17 Nov 2017 09:22:38 GMT
Server: Apache/2.4.18 (Ubuntu)
OpenStack-API-Version: compute 2.53
X-OpenStack-Nova-API-Version: 2.53
Vary: OpenStack-API-Version,X-OpenStack-Nova-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 193
x-openstack-request-id: req-f77858f8-dd77-4dcd-825a-aec012cabcfc
x-compute-request-id: req-f77858f8-dd77-4dcd-825a-aec012cabcfc
Connection: close
{"computeFault": {"message": "Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.\n<type 'exceptions.TypeError'>", "code": 500}}

Logs & Configs
==============
2017-11-19 20:19:03.567 9606 INFO sqlalchemy.engine.base.Engine [req-c1765f1e-786a-4457-9c45-2f8c3897722b - admin] ROLLBACK
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions [req-c1765f1e-786a-4457-9c45-2f8c3897722b - admin] Unexpected exception in API method: TypeError: 'in <string>' requires string as left operand, not NoneType
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions Traceback (most recent call last):
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/extensions.py", line 336, in wrapped
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions return f(*args, **kwargs)
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/compute/flavors.py", line 48, in detail
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions return self._view_builder.detail(req, limited_flavors)
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/compute/views/flavors.py", line 61, in detail
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions return self._list_view(self.show, request, flavors, coll_name)
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/compute/views/flavors.py", line 74, in _list_view
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions flavor_list = [func(request, flavor)["flavor"] for flavor in flavors]
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/compute/views/flavors.py", line 47, in show
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions self._collection_name),
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/common.py", line 390, in _get_links
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions "href": self._get_href_link(request, identifier, collection_name),
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/common.py", line 413, in _get_href_link
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions self._get_project_id(request),
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/common.py", line 383, in _get_project_id
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions if project_id in request.url:#project_id and project_id in request.url:
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions TypeError: 'in <string>' requires string as left operand, not NoneType
2017-11-19 20:19:03.571 9606 ERROR nova.api.openstack.extensions
2017-11-19 20:19:03.598 9606 INFO nova.api.openstack.wsgi [req-c1765f1e-786a-4457-9c45-2f8c3897722b - admin] HTTP exception thrown: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<type 'exceptions.TypeError'>
2017-11-19 20:19:03.600 9606 DEBUG nova.api.openstack.wsgi [req-c1765f1e-786a-4457-9c45-2f8c3897722b - admin] Returning 500 to user: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<type 'exceptions.TypeError'> __call__ /opt/stack/nova/nova/api/openstack/wsgi.py:1029
2017-11-19 20:19:03.602 9606 INFO nova.api.openstack.requestlog [req-c1765f1e-786a-4457-9c45-2f8c3897722b - admin] 10.76.6.31 "GET /compute/v2.1/flavors/detail" status: 500 len: 193 microversion: 2.53 time: 0.711753

Yikun Jiang (yikunkero)
summary: - Failed to get flavors(raise 500) with a domain scope(without
+ Failed to get flavors(raise 500) with a domain scope token(without
project_id).
Changed in nova:
assignee: nobody → Yikun Jiang (yikunkero)
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/522100

Changed in nova:
status: New → In Progress
Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/522100
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=036a692565ef0f1c730f28ea083465fad9dc3b13
Submitter: Zuul
Branch: master

commit 036a692565ef0f1c730f28ea083465fad9dc3b13
Author: Yikun Jiang <email address hidden>
Date: Tue Nov 21 22:21:12 2017 -0500

    Fix TypeError of _get_project_id when project_id is None

    If we get flavors with a domain token or an unscope token,
    the project id of this case is None, will raise "TypeError:
    'in <string>' requires string as left operand, not NoneType"
    in _get_project_id. So, first we need check whether project_id
    is None or not.

    We can just return '' if project_id is None.

    Change-Id: I8477d08a956a5b0262bd473254d9202738b6b65b
    Closes-Bug: #1733746

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/524687

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 17.0.0.0b2

This issue was fixed in the openstack/nova 17.0.0.0b2 development milestone.

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

Reviewed: https://review.openstack.org/524687
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=781a963c58a7bb84077de7c3056d148afae0d303
Submitter: Zuul
Branch: stable/pike

commit 781a963c58a7bb84077de7c3056d148afae0d303
Author: Yikun Jiang <email address hidden>
Date: Tue Nov 21 22:21:12 2017 -0500

    Fix TypeError of _get_project_id when project_id is None

    If we get flavors with a domain token or an unscope token,
    the project id of this case is None, will raise "TypeError:
    'in <string>' requires string as left operand, not NoneType"
    in _get_project_id. So, first we need check whether project_id
    is None or not.

    We can just return '' if project_id is None.

    Change-Id: I8477d08a956a5b0262bd473254d9202738b6b65b
    Closes-Bug: #1733746
    (cherry picked from commit 036a692565ef0f1c730f28ea083465fad9dc3b13)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 16.0.4

This issue was fixed in the openstack/nova 16.0.4 release.

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.