max_count and min_count should be converted into the type: int

Bug #1254616 reported by Ivan-Zhu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Ivan-Zhu

Bug Description

when create multiple servers, in nova v3 api, the min_count and min_count should be converted into the type: int. otherwise some problem will arise.

the tempest v3 tests log:
2013-11-25 16:04:21,000 Request: POST http://9.115.126.211:8774/v3/servers
2013-11-25 16:04:21,001 Request Headers: {'Content-Type': 'application/xml', 'Accept': 'application/xml', 'X-Auth-Token': '<Token omitted>'}
2013-11-25 16:04:21,001 Request Body: <?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1" name="multiple-create-test-tempest-917155335" os-multiple-create:max_count="2" os-multiple-create:return_reservation_id="True" xmlns:os-multiple-create="http://docs.openstack.org/compute/ext/multiplecreate/api/v3" image_ref="08850447-5bfc-49ab-a728-92c056829e99" flavor_ref="42" os-multiple-create:min_count="1"/>
2013-11-25 16:04:21,684 Response Status: 400
2013-11-25 16:04:21,684 Nova request id: req-3ad76a84-dfd1-4d5d-8bd9-8a5879b16b6f
2013-11-25 16:04:21,684 Response Headers: {'content-length': '203', 'date': 'Mon, 25 Nov 2013 08:04:21 GMT', 'content-type': 'application/xml; charset=UTF-8', 'connection': 'close'}
2013-11-25 16:04:21,684 Response Body: <badRequest code="400" xmlns="http://docs.openstack.org/compute/api/v1.1"><message>The server could not comply with the request since it is either malformed or otherwise incorrect.</message></badRequest>

nova v3 api log:
2013-11-25 16:04:21.679 ERROR nova.api.openstack.wsgi [req-3ad76a84-dfd1-4d5d-8bd9-8a5879b16b6f demo demo] Exception handling resource: coercing to Unicode: need string or buffer, long found
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi Traceback (most recent call last):
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 999, in _process_stack
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi action_result = self.dispatch(meth, request, action_args)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 1080, in dispatch
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi return method(req=request, **action_args)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/api/openstack/compute/plugins/v3/servers.py", line 773, in create
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi **create_kwargs)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/hooks.py", line 105, in inner
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi rv = f(*args, **kwargs)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/compute/api.py", line 1234, in create
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi legacy_bdm=legacy_bdm)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/compute/api.py", line 883, in _create_instance
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi block_device_mapping)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/compute/api.py", line 759, in _provision_instances
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi context, instance_type, min_count, max_count)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/compute/api.py", line 344, in _check_num_instances_quota
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi cores=req_cores, ram=req_ram)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/quota.py", line 1272, in reserve
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi user_id=user_id)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/quota.py", line 500, in reserve
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi project_id=project_id, user_id=user_id)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/db/api.py", line 1097, in quota_reserve
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi project_id=project_id, user_id=user_id)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 130, in wrapper
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi return f(*args, **kwargs)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 168, in wrapped
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi return f(*args, **kwargs)
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 3186, in quota_reserve
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi project_usages[res]['total'] or
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi TypeError: coercing to Unicode: need string or buffer, long found
2013-11-25 16:04:21.679 TRACE nova.api.openstack.wsgi
2013-11-25 16:04:21.682 DEBUG nova.api.openstack.wsgi [req-3ad76a84-dfd1-4d5d-8bd9-8a5879b16b6f demo demo] Returning 400 to user: The server could not comply with the request since it is either malformed or otherwise incorrect. from (pid=10829) __call__ /opt/stack/nova/nova/api/openstack/wsgi.py:1225
2013-11-25 16:04:21.683 INFO nova.osapi_compute.wsgi.server [req-3ad76a84-dfd1-4d5d-8bd9-8a5879b16b6f demo demo] 9.115.126.211 "POST /v3/servers HTTP/1.1" status: 400 len: 418 time: 0.6807010

Ivan-Zhu (ivan-zhu)
Changed in nova:
assignee: nobody → Ivan-Zhu (ivan-zhu)
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/58220

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

Reviewed: https://review.openstack.org/58220
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9b7d87181ba2406496c4b977a1b24c8173080ad6
Submitter: Jenkins
Branch: master

commit 9b7d87181ba2406496c4b977a1b24c8173080ad6
Author: ivan-zhu <email address hidden>
Date: Mon Nov 25 16:28:26 2013 +0800

    convert min_count and max_count to type int in nova v3 api

    this converts min_count and max_count to type:int in nova
    v3 api.
    If the string type hasn't been converted, in the method
    _check_num_instances_quota of nova/compute/api.py, something
    like req_ram = '2'*128 will occur. That's why the issue in
    bug 1254616 arise.

    Change-Id: I567b249e7a30681980ed760d5d09aad4c8e603b9
    Closes-bug: 1254616

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-2
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-2 → 2014.1
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.