Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed quota calculations for multiple vms in requested method. #128

Merged

Conversation

billfitzgerald0120
Copy link
Contributor

Values for cloud providers were incorrect when multiple vms were selected.
Included Azure to cloud providers which was missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1455844

@miq-bot add_label bug, fine/yes, euwe/yes

@billfitzgerald0120
Copy link
Contributor Author

@tinaafitz
Please Review

@tinaafitz
Copy link
Member

@billfitzgerald0120 Looks good.

Copy link
Member

@tinaafitz tinaafitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmcculloug Looks good, please review.

@miq_provision_request.options[:number_of_vms] = 3
@miq_provision_request.save
ws = run_automate_method(vm_attrs)
check_results(ws.root['quota_requested'], 30.gigabytes, 12, 3, 3072)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency 3072 should be 3.kilobytes.

def cloud_number_of_cpus(args_hash)
return unless args_hash[:flavor]
$evm.log(:info, "Retrieving cloud flavor #{args_hash[:flavor].name} cpus => #{args_hash[:flavor].cpus}")
default_option((args_hash[:flavor].cpus * args_hash[:number_of_vms]), args_hash[:options_array])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments that apply to the 3 cloud calculation methods update in this PR.

  1. The methods cloud_number_of_cpus, cloud_vm_memory and cloud_storage all start with the condition return unless args_hash[:flavor]. These methods are only called from one method cloud_value.

I would move this check into the caller and the methods can assume that they are being called only when a flavor is present in the hash.

  1. Constantly dereferencing args_hash[:flavor] is not efficient and makes the logic harder to read. Change the methods to set the variable flavor at the top of the methods.

As an example, with these two changes the cloud_vm_memory method would become:

def cloud_vm_memory(args_hash)
  flavor = args_hash[:flavor]

  $evm.log(:info, "Retrieving flavor #{flavor.name} memory => #{flavor.memory}")
  default_option((flavor.memory * args_hash[:number_of_vms]), args_hash[:options_array])
end

Note: Since the other two args_hash values are only referenced once I did not assign them to variables.

@billfitzgerald0120
Copy link
Contributor Author

@gmcculloug @tinaafitz Made all changes except for cloud_storage which doesn't use flavor for Google.

@gmcculloug
Copy link
Member

@billfitzgerald0120 @tinaafitz Is there a valid use-case where we are evaluating quota without the flavor selected? Understanding that Google does not need it for storage does it make sense doing the storage calculation for any of the cloud providers if we know memory and cpu values will be nil?

Also want to note that cloud_storage was checking for a valid flavor instance prior to this change regardless of the provider type.

-def cloud_storage(flavor, dialog_array, resource)
-  return unless flavor
-
-  storage = if provision_type(resource) == 'google'
-              get_option_value(resource, :boot_disk_size).gigabytes
+def cloud_storage(args_hash)
+  flavor = args_hash[:flavor]
+  storage = if provision_type(args_hash[:resource]) == 'google'

Just trying to rationalize the need for the added complexity.

cloud_vm_memory(args_hash[:flavor], args_hash[:options_array])
when :storage
cloud_storage(args_hash[:flavor], args_hash[:options_array], args_hash[:resource])
if args_hash[:flavor]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billfitzgerald0120 I would prefer this be an early return like the unless args_hash[:cloud] check above and avoid wrapping the case statement in a condition block.

Values for cloud providers were incorrect when multiple vms were selected.
Included Azure to cloud providers which was missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1455844
@miq-bot
Copy link
Member

miq-bot commented Jun 21, 2017

Checked commit billfitzgerald0120@88a75a6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@billfitzgerald0120
Copy link
Contributor Author

@gmcculloug @tinaafitz Made changes as requested.

@gmcculloug
Copy link
Member

@tinaafitz Can you give this one more quick review after the last round of changes?

Copy link
Member

@tinaafitz tinaafitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmcculloug gmcculloug merged commit 85dd441 into ManageIQ:master Jun 21, 2017
@gmcculloug gmcculloug added this to the Sprint 64 Ending Jul 3, 2017 milestone Jun 21, 2017
@simaishi
Copy link
Contributor

Euwe backport (to manageiq repo) details:

$ git log -1
commit be1febba336d189aef2437b5e003553e476e3332
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Jun 21 15:07:27 2017 -0400

    Merge pull request #128 from billfitzgerald0120/requested_number_of_vms
    
    Fixed quota calculations for multiple vms in requested method.
    (cherry picked from commit 85dd4414d6d6c4a8bc3b726bac5625974c7caad3)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1465088

simaishi pushed a commit that referenced this pull request Aug 4, 2017
Fixed quota calculations for multiple vms in requested method.
(cherry picked from commit 85dd441)

https://bugzilla.redhat.com/show_bug.cgi?id=1465087
@simaishi
Copy link
Contributor

simaishi commented Aug 4, 2017

Fine backport details:

$ git log -1
commit 30bba6f72010eb612e03e7cc254bd6e602bc69e6
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Jun 21 15:07:27 2017 -0400

    Merge pull request #128 from billfitzgerald0120/requested_number_of_vms
    
    Fixed quota calculations for multiple vms in requested method.
    (cherry picked from commit 85dd4414d6d6c4a8bc3b726bac5625974c7caad3)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1465087

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants