← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1484379] Re: Passing PD subnet_id in fixed_ips to port-create causes DBDuplicateEntry

 

** Changed in: neutron
       Status: Fix Committed => Fix Released

** Changed in: neutron
    Milestone: None => liberty-3

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

Title:
  Passing PD subnet_id in fixed_ips to port-create causes
  DBDuplicateEntry

Status in neutron:
  Fix Released

Bug description:
  Found this when testing the v6 prefix delegation patch
  https://review.openstack.org/#/c/185977/ and trying to use the debug-
  probe.

  Got a DB error when trying to create a port where the subnet id is
  passed in fixed ips.  Note this subnet has "subnetpool_id":
  "prefix_delegation".

  vagrant@node1:~$ curl -s -X  GET http://192.168.2.2:9696/v2.0/subnets/a524ad8d-644d-4f89-ade8-960dcbd8fb72.json -H "User-Agent: python-neutronclient" -H "Accept: application/json" -H "X-Auth-Token: 246cf05ad88843d0b4e76ae6dda6e6b6" | python -m json.tool
  {
      "subnet": {
          "allocation_pools": [
              {
                  "end": "2222:2222:2222:3c0f:ffff:ffff:ffff:ffff",
                  "start": "2222:2222:2222:3c0f::2"
              }
          ],
          "cidr": "2222:2222:2222:3c0f::/64",
          "dns_nameservers": [],
          "enable_dhcp": true,
          "gateway_ip": "2222:2222:2222:3c0f::1",
          "host_routes": [],
          "id": "a524ad8d-644d-4f89-ade8-960dcbd8fb72",
          "ip_version": 6,
          "ipv6_address_mode": "slaac",
          "ipv6_ra_mode": "slaac",
          "name": "sub6",
          "network_id": "26c63522-375a-49e8-8d37-bc0124c53076",
          "subnetpool_id": "prefix_delegation",
          "tenant_id": "48560abddfec4170bfdb5f6ed79e2847"
      }
  }

  
  vagrant@node1:~$ neutron port-create 26c63522-375a-49e8-8d37-bc0124c53076 --fixed_ips list=true type=dict subnet_id=a524ad8d-644d-4f89-ade8-960dcbd8fb72
  Request Failed: internal server error while processing your request.

  
  2015-08-13 06:34:08.363 DEBUG neutron.db.db_base_plugin_common [req-bfcdb604-1491-4108-912e-b960b4329d5d admin admin] Allocated IP 2222:2222:2222:3c0f:f816:3eff:fe3b:91c7 (26c63522-375a-49e8-8d37-bc0124c53076/a524ad8d-644d-4f89-ade8-960dcbd8fb72/0879bbc4-d3d0-4b57-ae6a-382757bcb330) _store_ip_allocation /opt/stack/neutron/neutron/db/db_base_plugin_common.py:68
  2015-08-13 06:34:08.363 DEBUG neutron.db.db_base_plugin_common [req-bfcdb604-1491-4108-912e-b960b4329d5d admin admin] Allocated IP 2222:2222:2222:3c0f:f816:3eff:fe3b:91c7 (26c63522-375a-49e8-8d37-bc0124c53076/a524ad8d-644d-4f89-ade8-960dcbd8fb72/0879bbc4-d3d0-4b57-ae6a-382757bcb330) _store_ip_allocation /opt/stack/neutron/neutron/db/db_base_plugin_common.py:68
  2015-08-13 06:34:08.370 ERROR neutron.api.v2.resource [req-bfcdb604-1491-4108-912e-b960b4329d5d admin admin] create failed
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource Traceback (most recent call last):
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     result = method(request=request, **args)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     ectxt.value = e.inner_exc
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in __exit__
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     six.reraise(self.type_, self.value, self.tb)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     return f(*args, **kwargs)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/opt/stack/neutron/neutron/api/v2/base.py", line 486, in create
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     obj = obj_creator(request.context, **kwargs)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 998, in create_port
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     result, mech_context = self._create_port_db(context, port)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 973, in _create_port_db
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     result = super(Ml2Plugin, self).create_port(context, port)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 1018, in create_port
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self.ipam.allocate_ips_for_port_and_store(context, port, port_id)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 490, in __exit__
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self.rollback()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 487, in __exit__
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self.commit()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 392, in commit
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self._prepare_impl()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self.session.flush()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2004, in flush
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self._flush(objects)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2122, in _flush
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     transaction.rollback(_capture_exception=True)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     compat.reraise(exc_type, exc_value, exc_tb)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2086, in _flush
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     flush_context.execute()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     rec.execute(self)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     uow
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     mapper, table, insert)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 728, in _emit_insert_statements
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     execute(statement, multiparams)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     return meth(self, multiparams, params)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     return connection._execute_clauseelement(self, multiparams, params)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     compiled_sql, distilled_params
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     context)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     util.raise_from_cause(newraise, exc_info)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     reraise(type(exception), exception, tb=exc_tb)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1116, in _execute_context
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     context)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 95, in do_executemany
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     rowcount = cursor.executemany(statement, parameters)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 155, in executemany
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self._get_db().encoding)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 190, in _do_execute_many
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     rows += self.execute(sql + postfix)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 134, in execute
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     result = self._query(query)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 282, in _query
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     conn.query(q)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 768, in query
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 929, in _read_query_result
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     result.read()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1125, in read
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     first_packet = self.connection._read_packet()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 893, in _read_packet
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     packet.check_error()
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 369, in check_error
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     err.raise_mysql_exception(self._data)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 120, in raise_mysql_exception
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     _check_mysql_exception(errinfo)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource   File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 112, in _check_mysql_exception
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource     raise errorclass(errno, errorvalue)
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource DBDuplicateEntry: (pymysql.err.IntegrityError) (1062, u"Duplicate entry '2222:2222:2222:3c0f:f816:3eff:fe3b:91c7-a524ad8d-644d-4f89-ade8-' for key 'PRIMARY'") [SQL: u'INSERT INTO ipallocations (port_id, ip_address, subnet_id, network_id) VALUES (%s, %s, %s, %s)'] [parameters: (('0879bbc4-d3d0-4b57-ae6a-382757bcb330', '2222:2222:2222:3c0f:f816:3eff:fe3b:91c7', u'a524ad8d-644d-4f89-ade8-960dcbd8fb72', u'26c63522-375a-49e8-8d37-bc0124c53076'), ('0879bbc4-d3d0-4b57-ae6a-382757bcb330', '2222:2222:2222:3c0f:f816:3eff:fe3b:91c7', u'a524ad8d-644d-4f89-ade8-960dcbd8fb72', u'26c63522-375a-49e8-8d37-bc0124c53076'))]
  2015-08-13 06:34:08.370 8032 ERROR neutron.api.v2.resource 
  2015-08-13 06:34:08.475 INFO neutron.wsgi [req-bfcdb604-1491-4108-912e-b960b4329d5d admin admin] 192.168.2.2 - - [13/Aug/2015 06:34:08] "POST /v2.0/ports.json HTTP/1.1" 500 383 0.248965

  
  Creating a port without specifying the subnet works:
  vagrant@node1:~$ neutron port-create 26c63522-375a-49e8-8d37-bc0124c53076
  Created a new port:
  ....

  And creating a port when the subnet has a blank subnetpool_id works
  vagrant@node1:~$ neutron port-create private --fixed_ips list=true type=dict subnet_id=a397013b-0dd2-47c7-ac5d-4e05943373fc
  Created a new port:
  ...

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


References