Bug 1376441 - The requested instance cannot be launched. The following requested resource(s) exceed quota(s): Cores(Available: 0, Requested: 1).
Summary: The requested instance cannot be launched. The following requested resource(s...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-django-horizon
Version: 7.0 (Kilo)
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 7.0 (Kilo)
Assignee: Radomir Dopieralski
QA Contact: Ido Ovadia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-15 12:39 UTC by Pablo Iranzo Gómez
Modified: 2019-12-16 06:46 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-29 08:51:24 UTC
Target Upstream Version:


Attachments (Terms of Use)
the quota_usages table for that tenant (1.93 KB, text/plain)
2016-10-21 11:34 UTC, Sebastien Aime
no flags Details
the live rows from the instances table for that tenant (218.00 KB, text/plain)
2016-10-21 11:34 UTC, Sebastien Aime
no flags Details
nova flavor-show output (86.56 KB, text/plain)
2016-11-02 12:30 UTC, Sebastien Aime
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2625861 0 None None None 2016-09-15 12:41:15 UTC

Description Pablo Iranzo Gómez 2016-09-15 12:39:13 UTC
Description of problem:

Horizon doesn't allow to launch a m1.small instance even if quotas for project are not yet consumed, but works for other projects and also works from CLI for that specific tenant.


Version-Release number of selected component (if applicable):

python-django-horizon-2015.1.2-4.el7ost.noarch
openstack-dashboard-2015.1.2-4.el7ost.noarch
openstack-dashboard-theme-2015.1.2-4.el7ost.noarch

Comment 3 Pablo Iranzo Gómez 2016-09-15 12:42:37 UTC
Error received on horizon:

"The requested instance cannot be launched. The following requested resource(s) exceed quota(s): Cores(Available: 0, Requested: 1)."

From the code below:


dashboards/project/instances/workflows/create_instance.py



    def _check_quotas(self, cleaned_data):
        count = cleaned_data.get('count', 1)

        # Prevent launching more instances than the quota allows
        usages = quotas.tenant_quota_usages(self.request)
        available_count = usages['instances']['available']
        if available_count < count:
            error_message = ungettext_lazy(
                'The requested instance cannot be launched as you only '
                'have %(avail)i of your quota available. ',
                'The requested %(req)i instances cannot be launched as you '
                'only have %(avail)i of your quota available.',
                count)
            params = {'req': count,
                      'avail': available_count}
            raise forms.ValidationError(error_message % params)

        flavor_id = cleaned_data.get('flavor')
        flavor = self._get_flavor(flavor_id)  

        count_error = []
        # Validate cores and ram.
        available_cores = usages['cores']['available']
        if flavor and available_cores < count * flavor.vcpus:
            count_error.append(_("Cores(Available: %(avail)s, "
                                 "Requested: %(req)s)")
                               % {'avail': available_cores,
                                  'req': count * flavor.vcpus})

        available_ram = usages['ram']['available']
        if flavor and available_ram < count * flavor.ram:
            count_error.append(_("RAM(Available: %(avail)s, "
                                 "Requested: %(req)s)")
                               % {'avail': available_ram,
                                  'req': count * flavor.ram})

        if count_error:
            value_str = ", ".join(count_error)
            msg = (_('The requested instance cannot be launched. '
                     'The following requested resource(s) exceed '
                     'quota(s): %s.') % value_str)
            if count == 1:
                self._errors['flavor'] = self.error_class([msg])
            else:
                self._errors['count'] = self.error_class([msg])



We're getting available cores as 0, this is gathered from "usages['cores']['available']"

Comment 28 Sebastien Aime 2016-10-21 11:34:14 UTC
Created attachment 1212811 [details]
the quota_usages table for that tenant

Comment 29 Sebastien Aime 2016-10-21 11:34:47 UTC
Created attachment 1212812 [details]
the live rows from the instances table for that tenant

Comment 32 Sebastien Aime 2016-11-02 12:30:35 UTC
Created attachment 1216527 [details]
nova flavor-show output

Hello,

please find attached the requested information.


Seb.

Comment 34 Radomir Dopieralski 2016-11-18 14:04:56 UTC
Hi,

I still didn't manage to pinpoint the source of discrepancy between the Nova's and Horizon's calculations, other than Nova reports vcpus numbers from actually deployed instances, while Horizon uses the numbers defined in their flavors. Those numbers should be the same, unless the flavors have been tampered with since the instances were deployed -- but I assume that we would have been told about it if that was the case.

I will try to ask the Nova team for advice again.

Comment 35 Radomir Dopieralski 2016-11-25 13:29:55 UTC
We will need some additional data. Can you please ask the customer for dumps of the tables "flavors" and "request_specs" from the "nova_api" database?

Comment 38 Radomir Dopieralski 2016-11-28 11:57:59 UTC
Thank you, that's exactly what I wanted to check.

It's not that Horizon didn't pick up the changes, it's that the instances that were launched before those changes were made didn't pick them up, and still run with the old number of vcpus. That is a perfectly normal and expected behavior, as it's impossible to update a running instance. This is also the reason why editing a flavor in Horizon makes it create a new flavor, and mark the old one as deleted, instead of just updating the database.

I'm not sure if there is much we can do in this situation. Of course, it would be much better if Horizon didn't calculate the quotas, but instead ask Nova for them, but that may be impossible to implement in this version, as it would be a new API call.

Comment 39 Radomir Dopieralski 2016-11-28 13:27:48 UTC
To sum up, Horizon calculates quotas assuming that all instances were launched with the current set of flavors, while Nova tracks how much resources the actual instances take. The discrepancy is there because some of the flavors were manually changed after launching some instances with them, so they no longer reflect accurately the resources that those instances take up.

The only way to avoid such a situation is to re-launch any instances that use flavors that have been modified, and, preferably, refrain from modifying flavors at all, creating new ones as needed instead.

Comment 40 Sebastien Aime 2016-11-28 14:16:11 UTC
Hi Radomir,

Thanks a lot for these updates, it's getting clear now. Do you know if in the long term there's a plan to add an API call to Nova to allow Horizon (or other software) to ask about resources consumption?

Cheers,

Seb.

Comment 41 Radomir Dopieralski 2016-11-28 14:25:35 UTC
There are plans to rework the quota code on the Horizon side quite extensively ( https://blueprints.launchpad.net/horizon/+spec/make-quotas-great-again ), however I am not entirely sure if this particular problem is going to be addressed by it and how exactly, as I was not involved in the planning. However, those problems have been reported before ( https://bugs.launchpad.net/horizon/+bug/1210533 https://bugs.launchpad.net/horizon/+bug/1277108 ) and I'm sure we will get to them sooner or later.

Comment 42 Sebastien Aime 2016-11-29 08:49:20 UTC
Hello,

Yesterday we've found the explanation and our customer is now happy with it.
After having done a few more tests, they have closed their support case.

We can close this BZ now.

Cheers,

Seb.

Comment 43 Radomir Dopieralski 2016-11-29 08:51:24 UTC
Thank you!


Note You need to log in before you can comment on or make changes to this bug.