Private flavors can't be used

Bug #1083602 reported by Marco CONSONNI
28
This bug affects 5 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Opinion
Wishlist
Unassigned

Bug Description

I'm testing nova client 2.9.0.

I worked as a user with admin privileges.

I created a private flavor with command:

$ nova flavor-create myFlavor 10 512 1 1 --is-public false
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 10 | myFlavor | 512 | 1 | 0 | | 1 | 1 | False | {} |
+----+----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+

Then, I associated the just created flavor to the tenant I was using with command:

$ nova flavor-access-add 10 admin
+-----------+-----------+
| Flavor_ID | Tenant_ID |
+-----------+-----------+
| 10 | admin |
+-----------+-----------+

If I list the flavors, with command nova flavor-list, the new flavor is not displayed:

$ nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+

Even in the case I list with this other command, the new flavor is not shown:

$ nova flavor-access-list --flavor=10
ERROR: Failed to get access list for public flavor type.

$ nova flavor-access-list --tenant admin
ERROR: Sorry, query by tenant not supported.

Please note that I get the same results if I don't associate the private flavor to any project.

According to the specification I found here https://blueprints.launchpad.net/nova/+spec/project-specific-flavors, It seems to me that private flavor types are not working.

Tags: flavor
Revision history for this message
Marco CONSONNI (marco-consonni) wrote :

More information and, very likely, a different bug.

I launched an instance using the private flavor and it worked.
Fine!
So, what I reported when I opened the bug seems to be related to display.

But, if I change the current project (aka tenant), I can still use the flavor that's supposed to be private.

In fact I changed the current user and the current tenant, the latter is NOT associated to the private flavor.

Then I launched an instance indicating the private flavor I created.

$ nova boot testFlavor10Marco1 --image f413b150-48d3-4c50-a265-9711805cce17 --flavor 10

+------------------------+--------------------------------------+
| Property | Value |
+------------------------+--------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | qdsRTn27B7Wb |
| config_drive | |
| created | 2012-11-27T15:18:57Z |
| flavor | myFlavor |
| hostId | |
| id | 8d1ad41a-f3fc-4b39-9a8a-274f3d1f6692 |
| image | cirros-0.3.0-x86_64-disk |
| key_name | None |
| metadata | {} |
| name | testFlavor10Marco1 |
| progress | 0 |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| tenant_id | 2648f9f2fa894e2c82d2f29aa1b0fc37 |
| updated | 2012-11-27T15:19:00Z |
| user_id | 3af9666f4e504c65b6b2c3257e8c752d |
+------------------------+--------------------------------------+

The operation succeed but it shouldn't because the tenant I'm using is NOT associated to the private flavor.

Revision history for this message
Marco CONSONNI (marco-consonni) wrote :

Another strange behavior.

I submitted the following command indicating the private flavor I created:

$ nova flavor-show 10
+----------------------------+----------+
| Property | Value |
+----------------------------+----------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 30 |
| extra_specs | {} |
| id | 10 |
| name | myFlavor |
| os-flavor-access:is_public | True |
| ram | 700 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 3 |
+----------------------------+----------+

It's interesting to notice that os-flavor-access:is_public is set to TRUE but, if submit the 'plain' command nova flavor-list, flavor 10 is not displayed (it is not public, as expected). This is also confirmed by looking in mysql DB where I find that flag is_public is set to 0.

Given that, what's the meaning of os-flavor-access:is_public ?

Chuck Short (zulcss)
Changed in nova:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Sulochan Acharya (sulochan-acharya) wrote :

I was albe to replicate this. I was able to create an instance from a NON public flavor I have NO access to.

Changed in nova:
assignee: nobody → Sulochan Acharya (sulochan-acharya)
Revision history for this message
Belmiro Moreira (moreira-belmiro-email-lists) wrote :

I'm able to reproduce this.
There is anyone working on it?

Revision history for this message
hzrandd (82433422-a) wrote :

Hi, I am very honored to share ideas. i want to prevent other tenants accessing my private flavor, such as these commands nova

flavor-list ,nova flavor-show . We all know that only administrator can run these commands,such as create flavor and

nova flavor-access-add.

codes: (flavors.py)
def show(self, req, id):
    """Return data about the given flavor id."""
    try:
    flavor = instance_types.get_instance_type_by_flavor_id(id)
    context = req.environ['nova.context']
    if not context.is_admin:
        flavors = self._get_flavors(req)
        flavor_is_not = False
        for k in flavors:
            if k.get('flavorid', None) != flavor.get('flavorid', None)\
                               and flavor.get('is_public', None) == False:
                flavor_is_not = True
        if flavor_is_not:
            raise webob.exc.HTTPNotFound()
    req.cache_db_flavor(flavor)
    except exception.NotFound:
        raise webob.exc.HTTPNotFound()

    return self._view_builder.show(req, flavor)

Changed in nova:
assignee: Sulochan Acharya (sulochan-acharya) → nobody
Revision history for this message
Feodor Tersin (ftersin) wrote :

It seems that multiple problems are raised here:

1) $ nova flavor-access-add <flavor_id> <tenant_name>
adds a rule which is never used.
In fact a correct way to add access to a flavor is to use tenant_id instead of tenant_name.
Nova should reject such requests. Novaclient should convert tenant_name to tenant_id as it is done for objects of another types.
But since OS could work with no Keystone, it seems not possible to verify a tenant id, or get a tenant id by a tenant name.

2) An admin role user can run an instance with a flavor which isn't available for the instance tenant.
But the same happens to an image. If the image is private and isn't visible in a tenant, an admin can boot an instnace in the tenant from this image. I guess the same happens for volumes and snapshots as well.
So this looks like a feature and shouldn't be fixed separately from images/volumes/snapshots/etc.

3) A filter by is_public property isn't available for novaclient cli.
The filter was promised by the blueprint.

4) A filter by a tenant isn't available for neither REST nor cli.
The filter was promised by the blueprint.

5) Under some circumstances a private flavor become public.
It's not reproduced for me.

Something else?

Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

The last check was done 1 year ago and this report describes multiple issues at once. There is not enough time to double-check each bug report. I'm closing this one. If you want to work on that, consider opening new bug reports, each one with one single and very specific issue. Otherwise it's not possible to solve them completely.

Changed in nova:
status: Confirmed → Opinion
Revision history for this message
watanabe.isao (watanabe.isao) wrote :

Hello, @Feodor Tersin (ftersin)

Have you (or your co-worker) distributed the bugs mentioned in #6?
If yes, could you post the link here?

Revision history for this message
watanabe.isao (watanabe.isao) wrote :

I just found that another bug [1] has mentioned this bug.
And [1]'s duplicated bug [2] has been fixed 3 days ago(2017/5/6)...

Note that, there is a BP [3].

[1]https://bugs.launchpad.net/nova/+bug/1317515
[2]https://bugs.launchpad.net/nova/+bug/1544989
[3]https://blueprints.launchpad.net/nova/+spec/validate-project-with-keystone

Revision history for this message
Feodor Tersin (ftersin) wrote :

Hi. No, i have not. I just posted that comment, nothing more.

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.