← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1995732] Re: bulk port create: TypeError: Bad prefix type for generating IPv6 address by EUI-64

 

Reviewed:  https://review.opendev.org/c/openstack/neutron/+/863881
Committed: https://opendev.org/openstack/neutron/commit/f7dd7790f5c6e3149af4680ba521089328d1eb0c
Submitter: "Zuul (22348)"
Branch:    master

commit f7dd7790f5c6e3149af4680ba521089328d1eb0c
Author: elajkat <lajos.katona@xxxxxxxx>
Date:   Fri Nov 4 16:51:03 2022 +0100

    Fix bulk create without mac
    
    Bulk port create without mac address fails as when Neutron calls
    oslo_utils.netutils.get_ipv6_addr_by_EUI64, as the mac field of the port
    is an ATTR_NOT_SPECIFIED Sentinel() object.
    With some reshuffling of the code to fill the mac field this can be
    fixed.
    
    Closes-Bug: #1995732
    Related-Bug: #1954763
    
    Change-Id: Id594003681f4755d8fd1af3b98e281c3109420f6


** Changed in: neutron
       Status: In Progress => Fix Released

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

Title:
  bulk port create: TypeError: Bad prefix type for generating IPv6
  address by EUI-64

Status in neutron:
  Fix Released

Bug description:
  source openrc admin admin
  export TOKEN="$( openstack token issue -f value -c id )"

  A single port create succeeds:
  curl -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -d "{\"port\":{\"name\":\"port0\",\"network_id\":\"$( openstack net show private -f value -c id )\"}}" -X POST http://127.0.0.1:9696/networking/v2.0/ports | json_pp
  ...

  But the same request via the bulk api fails:
  curl -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -d "{\"ports\":[{\"name\":\"port0-via-bulk\",\"network_id\":\"$( openstack net show private -f value -c id )\"}]}" -X POST http://127.0.0.1:9696/networking/v2.0/ports | json_pp
  {
     "NeutronError" : {
        "detail" : "",
        "message" : "Request Failed: internal server error while processing your request.",
        "type" : "HTTPInternalServerError"
     }
  }

  While in q-svc logs we have:
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation [None req-f5c79830-013a-4ae2-8c47-2102b20299e1 admin admin] POST failed.: TypeError: Bad prefix type for generating IPv6 address by EUI-64: fdd6:813:349::/64
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation Traceback (most recent call last):
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/netutils.py", line 210, in get_ipv6_addr_by_EUI64
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     eui64 = int(netaddr.EUI(mac).eui64())
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/netaddr/eui/__init__.py", line 389, in __init__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.value = addr
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/netaddr/eui/__init__.py", line 425, in _set_value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self._value = module.str_to_int(value)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/netaddr/strategy/eui48.py", line 178, in str_to_int
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise TypeError('%r is not str() or unicode()!' % (addr,))
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation TypeError: <neutron_lib.constants.Sentinel object at 0x7fb8a4f91060> is not str() or unicode()!
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation During handling of the above exception, another exception occurred:
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation Traceback (most recent call last):
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/pecan/core.py", line 693, in __call__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.invoke_controller(controller, args, kwargs, state)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/pecan/core.py", line 584, in invoke_controller
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     result = controller(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 140, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception():
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 138, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_db/api.py", line 144, in wrapper
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception() as ectxt:
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_db/api.py", line 142, in wrapper
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 186, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception():
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 184, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*dup_args, **dup_kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/pecan_wsgi/controllers/utils.py", line 65, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/pecan_wsgi/controllers/resource.py", line 163, in post
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return self.create(resources)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/pecan_wsgi/controllers/resource.py", line 181, in create
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return {key: creator(*creator_args, **creator_kwargs)}
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/common/utils.py", line 704, in inner
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1619, in create_port_bulk
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     port_list = self.allocate_ips_for_ports(context, port_list)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1604, in allocate_ips_for_ports
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     port['ipams'] = self.ipam.allocate_ips_for_port(context, port)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 226, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f_with_retry(*args, **kwargs,
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 140, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception():
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 138, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_db/api.py", line 144, in wrapper
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception() as ectxt:
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_db/api.py", line 142, in wrapper
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 186, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception():
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron-lib/neutron_lib/db/api.py", line 184, in wrapped
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return f(*dup_args, **dup_kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 1010, in wrapper
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return fn(*args, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/db/ipam_pluggable_backend.py", line 226, in allocate_ips_for_port
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return self._allocate_ips_for_port(context, port)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/db/ipam_pluggable_backend.py", line 287, in _allocate_ips_for_port
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return self._ipam_allocate_ips(context, ipam_driver, p, ips)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/db/ipam_pluggable_backend.py", line 146, in _ipam_allocate_ips
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     with excutils.save_and_reraise_exception():
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 227, in __exit__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     self.force_reraise()
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/excutils.py", line 200, in force_reraise
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise self.value
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/db/ipam_pluggable_backend.py", line 136, in _ipam_allocate_ips
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     ip_request = factory.get_request(context, port, ip_list[0])
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/ipam/requests.py", line 299, in get_request
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return AutomaticAddressRequest(prefix=ip_dict['subnet_cidr'],
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/ipam/requests.py", line 269, in __init__
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     address = address_generator(self, **kwargs)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/opt/stack/neutron/neutron/ipam/requests.py", line 251, in _generate_eui64_address
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     return netutils.get_ipv6_addr_by_EUI64(prefix, mac_address)
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation   File "/usr/local/lib/python3.10/dist-packages/oslo_utils/netutils.py", line 218, in get_ipv6_addr_by_EUI64
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation     raise TypeError(_('Bad prefix type for generating IPv6 address by '
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation TypeError: Bad prefix type for generating IPv6 address by EUI-64: fdd6:813:349::/64
  nov 04 15:56:52 devstack0 neutron-server[101377]: ERROR neutron.pecan_wsgi.hooks.translation

  The subnet range is devstack's default ipv6-private-subnet:
  $ openstack subnet show ipv6-private-subnet
  +----------------------+----------------------------------------------------+
  | Field                | Value                                              |
  +----------------------+----------------------------------------------------+
  | allocation_pools     | fdd6:813:349::2-fdd6:813:349:0:ffff:ffff:ffff:ffff |
  | cidr                 | fdd6:813:349::/64                                  |
  | created_at           | 2022-11-04T15:48:41Z                               |
  | description          |                                                    |
  | dns_nameservers      |                                                    |
  | dns_publish_fixed_ip | None                                               |
  | enable_dhcp          | True                                               |
  | gateway_ip           | fdd6:813:349::1                                    |
  | host_routes          |                                                    |
  | id                   | 3fa2abae-9978-4e37-a873-942820a5817b               |
  | ip_version           | 6                                                  |
  | ipv6_address_mode    | slaac                                              |
  | ipv6_ra_mode         | slaac                                              |
  | name                 | ipv6-private-subnet                                |
  | network_id           | 472fd184-51f1-4c42-a158-8d78bd57453f               |
  | project_id           | 347272392030462f86d01f59fa98c288                   |
  | revision_number      | 0                                                  |
  | segment_id           | None                                               |
  | service_types        |                                                    |
  | subnetpool_id        | 111f3f8b-e8cd-44b9-a874-a789989ef4f5               |
  | tags                 |                                                    |
  | updated_at           | 2022-11-04T15:48:41Z                               |
  +----------------------+----------------------------------------------------+

  neutron e4cc40f114
  devstack 0d5c8d66

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



References