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

Bug #1401171 reported by Vladik Romanovsky
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Sahid Orentino

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

Changed in nova:
assignee: nobody → Vladik Romanovsky (vladik-romanovsky)
Joe Gordon (jogo)
Changed in nova:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/140888

Changed in nova:
status: Confirmed → In Progress
Changed in nova:
assignee: Vladik Romanovsky (vladik-romanovsky) → sahid (sahid-ferdjaoui)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/140888
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=00bfc54403c9d918469963276338f2c0f1f3bb63
Submitter: Jenkins
Branch: master

commit 00bfc54403c9d918469963276338f2c0f1f3bb63
Author: Vladik Romanovsky <email address hidden>
Date: Wed Dec 10 17:29:37 2014 -0500

    Reply with a meaningful exception when ports are over the quota limit

    Currently, neutron client api returns a negative number
    for max_net_count, when the number of port is over the quota limit,
    instead of raising a meaningful exception.
    Raising an PortLimitExceeded exception, when the above issue occur.

    Closes-Bug: #1401171
    Change-Id: I5c9c7276f1d90e856ecc6b8c40e7efab4a625796

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-2 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.