Bug 1608230

Summary: CFME should not assign flavor id in OSP provider.
Product: Red Hat CloudForms Management Engine Reporter: Keigo Noha <knoha>
Component: ProvidersAssignee: Sam Lucidi <slucidi>
Status: CLOSED CURRENTRELEASE QA Contact: Ido Ovadia <iovadia>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.9.4CC: gblomqui, jfrey, jhajyahy, jhardy, jocarter, obarenbo, simaishi, slucidi, smallamp
Target Milestone: GAKeywords: FutureFeature, TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.10.0.23 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1653417 (view as bug list) Environment:
Last Closed: 2019-02-11 14:18:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Openstack Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1653417    

Description Keigo Noha 2018-07-25 07:27:45 UTC
Description of problem:
CFME should not assign flavor id in OSP provider.

Currently, CFME has following code
-- gems/fog-openstack-0.1.25/lib/fog/compute/openstack/requests/create_flavor.rb
~~~
      1 module Fog
      2   module Compute
      3     class OpenStack
      4       class Real
      5         # PARAMETERS #
      6         # name        = Name of flavor
      7         # ram         = Memory in MB
      8         # vcpus       = Number of VCPUs
      9         # disk        = Size of local disk in GB
     10         # swap        = Swap space in MB
     11         # rxtx_factor = RX/TX factor
     12         def create_flavor(attributes)
     13           # Get last flavor id
     14           flavor_ids = []
     15           flavors = list_flavors_detail.body['flavors'] + list_flavors_detail(:is_public => false).body['flavors']
     16           flavors.each do |flavor|
     17             flavor_ids << flavor['id'].to_i
     18           end
     19 
     20           # Set flavor id
     21           attributes[:flavor_id] = attributes[:flavor_id] || (!flavor_ids.empty? ? flavor_ids.sort.last + 1 : 1)
     22 
     23           data = {
     24             'flavor' => {
     25               'name'                       => attributes[:name],
     26               'ram'                        => attributes[:ram],
     27               'vcpus'                      => attributes[:vcpus],
     28               'disk'                       => attributes[:disk],
     29               'id'                         => attributes[:flavor_id],
     30               'swap'                       => attributes[:swap],
     31               'OS-FLV-EXT-DATA:ephemeral'  => attributes[:ephemeral],
     32               'os-flavor-access:is_public' => attributes[:is_public],
     33               'rxtx_factor'                => attributes[:rxtx_factor]
     34             }
     35           }
     36 
~~~

In this code, the new flavor ID is calculated as the largest number plus 1.

On the other hand, in OpenStack, flavor id is optional parameter. If it is not specified, OpenStack will use a UUID for its id.
The implementation difference in CFME and OpenStack causes following situation.
~~~
# openstack flavor list
+--------------------------------------+--------------+-------+------+-----------+-------+-----------+
| ID                                   | Name         |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+--------------+-------+------+-----------+-------+-----------+
| 00a6caa6-70b4-4843-955a-e2b144c85fbc | test_flavor  |  1024 |   10 |         0 |     1 | True      |
| 1                                    | m1.tiny      |   512 |    1 |         0 |     1 | True      |
| 2                                    | m1.small     |  2048 |   20 |         0 |     1 | True      |
| 3                                    | m1.medium    |  4096 |   40 |         0 |     2 | True      |
| 4                                    | m1.large     |  8192 |   80 |         0 |     4 | True      |
| 5                                    | m1.xlarge    | 16384 |  160 |         0 |     8 | True      |
| 6                                    | cfme_flavor  |  1024 |   20 |         0 |     2 | True      |
| 669fa648-1596-4327-9aae-85d6e5814216 | test2_flavor | 10240 |  100 |        50 |    10 | True      |
| 670                                  | cfme_flavor2 |  4096 |   30 |         0 |     6 | True      |
+--------------------------------------+--------------+-------+------+-----------+-------+-----------+
~~~

In this case, test2_flavor was created with 'openstack' command.
After that, cfme_flavor2 was created from the latest CFME.

Current implementation in CFME assumes that the flavor id is always decimal number.
But, UUID is used in actual usecase.

In OpenStack side, flavor id is not mandatory option in creating flavor.
CFME should not assign flavor id by itself. OpenStack should handle it.

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

How reproducible:
Everytime

Steps to Reproduce:
1. Setup OSP provider
2. Create a flavor in RHOSP whose id is UUID.
3. Create a flavor from CFME.

Actual results:
CFME always generate numeric ID.

Expected results:
CFME doesn't send a flavor id at creating flavor to OpenStack.

Comment 2 Sam Lucidi 2018-08-07 20:48:07 UTC
https://github.com/fog/fog-openstack/pull/411

Comment 3 Sam Lucidi 2018-08-08 16:34:39 UTC
Once the Fog PR is merged we'll still have to wait for a new release of Fog and an update to the gemspec in the openstack provider repo before this can go to POST.

Comment 6 Keigo Noha 2018-10-23 07:27:18 UTC
Hello Sam,

Do we have any updates on this bugzilla?

Best Regards,
Keigo Noha

Comment 7 Sam Lucidi 2018-10-26 19:17:59 UTC
Fog has been updated, setting this to POST.

Comment 9 Jad Haj Yahya 2018-11-19 09:35:08 UTC
Verified on 5.10.0.24