← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1483022] Re: Missing string substitution results in ugly exception

 

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

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

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1483022

Title:
  Missing string substitution results in ugly exception

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  nova/network/neutronv2/api.py's _create_port method can raise an
  InvalidInput exception.  The issue is that the msg_fmt of InvalidInput
  is:

  class InvalidInput(Invalid):
      msg_fmt = _("Invalid input received: %(reason)s")

  within api.py:
      msg = (_('Fixed IP %(ip)s is not a valid ip address for '
                        'network %(network_id)s.'),
                    {'ip': fixed_ip, 'network_id': network_id})
      raise exception.InvalidInput(reason=msg)

  This results in the reason not being properly created, which results
  in:

     File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 670, in allocate_for_instance
       self._delete_ports(neutron, instance, created_port_ids)
     File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 119, in __exit__
       six.reraise(self.type_, self.value, self.tb)
     File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 662, in allocate_for_instance
       security_group_ids, available_macs, dhcp_opts)
     File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 306, in _create_port
       raise exception.InvalidInput(reason=msg)
  InvalidInput: Invalid input received: (u'Fixed IP %(ip)s is not a valid ip address for network %(network_id)s.', {'network_id': u'7692e1e6-3404-4a56-9aec-3588dbd75275', 'ip': '8.8.8.8'})

  Simply substituting the kwargs into msg before raising the exception
  fixes the issue.

  within api.py:
      msg = (_('Fixed IP %(ip)s is not a valid ip address for '
                        'network %(network_id)s.') %
                    {'ip': fixed_ip, 'network_id': network_id})
      raise exception.InvalidInput(reason=msg)

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


References