← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1401171] [NEW] Instance creation fails with with HTTP 500 - IndexError: list index out of range

 

Public bug reported:

The problem is happening when there are more ports created in neutron than the
quota on it.

In this case, neutron client api will return a negative number for
max_net_count, which will be used as a total number of instances that should
be provisioned, and as a result none are being provisioned.
This caused the above exception to be raised.


_create_instance() 
    |
    |--> base_options, max_net_count = self._validate_and_build_base_options()
    |                                                            |
    |     max_network_count = self._check_requested_networks()<--'
    |                                            |
    |     self.network_api.validate_networks()<--'
    |        |
    |        `--> 
    |            free_ports = quotas.get('port') - len(ports)
    |            ports_needed = ports_needed_per_instance * num_instances
    |            if free_ports >= ports_needed:
    |                return num_instances 
    |            else:
    |                return free_ports // ports_needed_per_instance
    |
    | # Continuing in _create_instance max_count gets the value of
    | # max_net_count:
    |
    |-->  elif max_net_count < max_count:
    |         LOG.debug(_("max count reduced from %(max_count)d to "
    |                     "%(max_net_count)d due to network port quota"),
    |                     {'max_count': max_count,
    |                      'max_net_count': max_net_count})
    |         max_count = max_net_count
    |
    | # Now, _provision_instances is being called to provision a negative
    | # number of instances
    |--> instances = self._provision_instances(context, instance_type,
                min_count, max_count, base_options, boot_meta, security_groups,
                block_device_mapping)
                |
                `-> LOG.debug(_("Going to run %s instances..") % num_instances)
                    instances = []
                    try:
                        for i in xrange(num_instances):
                            instance = instance_obj.Instance()
                            instance.update(base_options)
                            instance = self.create_db_entry_for_new_instance(
                                  context, instance_type, boot_meta, instance,
                                  security_groups, block_device_mapping,
                                  num_instances, i)

                            instances.append(instance)
                    ...
                    return instances # this will return an empty list.
                    
server = self._view_builder.create(req, instances[0])   
IndexError: list index out

** Affects: nova
     Importance: Undecided
     Assignee: Vladik Romanovsky (vladik-romanovsky)
         Status: New

** Changed in: nova
     Assignee: (unassigned) => Vladik Romanovsky (vladik-romanovsky)

-- 
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/1401171

Title:
  Instance creation fails with with HTTP 500 - IndexError: list index
  out of range

Status in OpenStack Compute (Nova):
  New

Bug description:
  The problem is happening when there are more ports created in neutron than the
  quota on it.

  In this case, neutron client api will return a negative number for
  max_net_count, which will be used as a total number of instances that should
  be provisioned, and as a result none are being provisioned.
  This caused the above exception to be raised.

  
  _create_instance() 
      |
      |--> base_options, max_net_count = self._validate_and_build_base_options()
      |                                                            |
      |     max_network_count = self._check_requested_networks()<--'
      |                                            |
      |     self.network_api.validate_networks()<--'
      |        |
      |        `--> 
      |            free_ports = quotas.get('port') - len(ports)
      |            ports_needed = ports_needed_per_instance * num_instances
      |            if free_ports >= ports_needed:
      |                return num_instances 
      |            else:
      |                return free_ports // ports_needed_per_instance
      |
      | # Continuing in _create_instance max_count gets the value of
      | # max_net_count:
      |
      |-->  elif max_net_count < max_count:
      |         LOG.debug(_("max count reduced from %(max_count)d to "
      |                     "%(max_net_count)d due to network port quota"),
      |                     {'max_count': max_count,
      |                      'max_net_count': max_net_count})
      |         max_count = max_net_count
      |
      | # Now, _provision_instances is being called to provision a negative
      | # number of instances
      |--> instances = self._provision_instances(context, instance_type,
                  min_count, max_count, base_options, boot_meta, security_groups,
                  block_device_mapping)
                  |
                  `-> LOG.debug(_("Going to run %s instances..") % num_instances)
                      instances = []
                      try:
                          for i in xrange(num_instances):
                              instance = instance_obj.Instance()
                              instance.update(base_options)
                              instance = self.create_db_entry_for_new_instance(
                                    context, instance_type, boot_meta, instance,
                                    security_groups, block_device_mapping,
                                    num_instances, i)

                              instances.append(instance)
                      ...
                      return instances # this will return an empty list.
                      
  server = self._view_builder.create(req, instances[0])   
  IndexError: list index out

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


Follow ups

References