Creating metadef namespace with resource type raises 500 when called twice

Bug #1463036 reported by Kamil Rykowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
In Progress
Undecided
Kamil Rykowski

Bug Description

When you are trying to create a namespace with associated resource type and you send the request to the API twice you will get 500 response on the second call. Interesting behavior, because if you just want to create a namespace without any associated resource type it will pass on every call.

Tested on the latest master branch.

Reproduce:
URL: http://localhost:9292/v2/metadefs/namespaces
Method: POST
Payload:
{
            "namespace": "MyNamespace",
            "display_name": "DisplayName",
            "resource_type_associations": [
                {
                    "name": "MyResourceType"
                }
            ]
}

Traceback:
<...>
File "/opt/stack/glance/glance/api/v2/metadef_namespaces.py", line 130, in create
    rs_repo.add(new_resource)
  File "/opt/stack/glance/glance/domain/proxy.py", line 378, in add
    meta_resource_type))
  File "/opt/stack/glance/glance/notifier.py", line 744, in add
    md_resource_type)
  File "/opt/stack/glance/glance/domain/proxy.py", line 378, in add
    meta_resource_type))
  File "/opt/stack/glance/glance/api/policy.py", line 553, in add
    return super(MetadefResourceTypeRepoProxy, self).add(resource_type)
  File "/opt/stack/glance/glance/domain/proxy.py", line 378, in add
    meta_resource_type))
  File "/opt/stack/glance/glance/db/__init__.py", line 641, in add
    self._format_resource_type_to_db(resource_type)
  File "/opt/stack/glance/glance/db/sqlalchemy/api.py", line 1623, in metadef_resource_type_association_create
    context, namespace_name, values, session)
  File "/opt/stack/glance/glance/db/sqlalchemy/metadef_api/resource_type_association.py", line 168, in create
    context, namespace_name, session)
  File "/opt/stack/glance/glance/db/sqlalchemy/metadef_api/namespace.py", line 219, in get
    namespace_rec = _get_by_name(context, name, session)
  File "/opt/stack/glance/glance/db/sqlalchemy/metadef_api/namespace.py", line 113, in _get_by_name
    namespace_rec = query.one()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2407, in one
    "Multiple rows were found for one()")
MultipleResultsFound: Multiple rows were found for one()

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

Fix proposed to branch: master
Review: https://review.openstack.org/190125

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on glance (master)

Change abandoned by Glance Bot (<email address hidden>) on branch: master
Review: https://review.openstack.org/190125

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.