← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1463036] [NEW] Creating metadef namespace with resource type raises 500 when called twice

 

Public bug reported:

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()

** Affects: glance
     Importance: Undecided
     Assignee: Kamil Rykowski (kamil-rykowski)
         Status: In Progress


** Tags: metadef

** Changed in: glance
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1463036

Title:
  Creating metadef namespace with resource type raises 500 when called
  twice

Status in OpenStack Image Registry and Delivery Service (Glance):
  In Progress

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()

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1463036/+subscriptions


Follow ups

References