Bug 1392652 - quota limits.rb treats storage as MB instead of GB quota_source is not tenant
Summary: quota limits.rb treats storage as MB instead of GB quota_source is not tenant
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: cfme-future
Assignee: Tina Fitzgerald
QA Contact: Milan Falešník
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-08 01:03 UTC by Jeffrey Cutter
Modified: 2017-02-07 15:04 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-21 16:40:19 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)
Quota class schema (85.36 KB, image/png)
2016-11-10 20:44 UTC, Tina Fitzgerald
no flags Details
Tag max storage (43.80 KB, image/png)
2016-11-10 20:45 UTC, Tina Fitzgerald
no flags Details
Tag max memory (46.15 KB, image/png)
2016-11-10 20:45 UTC, Tina Fitzgerald
no flags Details

Description Jeffrey Cutter 2016-11-08 01:03:43 UTC
Description of problem:

ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb calculates $evm.parent[attr] for storage as MB when it is entered in tags and ManageIQ/System/CommonMethods/QuotaStateMachine/quota as GB.


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

5.6.2.2

Additional info:


$ git diff ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb
diff --git i/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb w/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb
index 37dde67..788b211 100644
--- i/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb
+++ w/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/limits.rb
@@ -42,7 +42,9 @@ end
 def parent_model_value(attr)
   value = $evm.parent[attr].to_i
   $evm.log(:info, "Quota Model #{attr}: #{value}") unless value.zero?
-  if attr.ends_with?("storage") || attr.ends_with?("memory")
+  if attr.ends_with?("storage")
+    value = value.gigabytes
+  elsif attr.ends_with?("memory")
     value = value.megabytes
   end
   value

Comment 2 Tina Fitzgerald 2016-11-10 20:44:32 UTC
Created attachment 1219542 [details]
Quota class schema

Comment 3 Tina Fitzgerald 2016-11-10 20:45:11 UTC
Created attachment 1219543 [details]
Tag max storage

Comment 4 Tina Fitzgerald 2016-11-10 20:45:42 UTC
Created attachment 1219544 [details]
Tag max memory

Comment 5 Tina Fitzgerald 2016-11-10 20:50:39 UTC
Hi Jeffrey,

The tag category descriptions for “Quota - Max Memory" and “Quota -
Max Storage” both say (GB),  but the tag values for memory and storage
are inconsistent.

For example,
the tag value for “Quota - Storage” 10GB is 10.
the tag value for “Quota - Memory” 10GB is 10240.
(see screenshots)

The limits quota method tag_value adjusts for this:
def tag_value(tag, tag_value)
  value = tag_value.to_i
  $evm.log(:info, "Quota Tag #{tag}: #{value}") unless value.zero?
  if tag == :quota_max_storage
    value = value.gigabytes
  elsif tag == :quota_max_memory
    value = value.megabytes
  end
  value
end

The ManageIQ/System/CommonMethods/QuotaMethods/quota instance values
($evm.parent[attr]) are in megabytes.

The default instance values for the
ManageIQ/System/CommonMethods/QuotaMethods/quota
Storage Warning Limit is 1024(1GB)
Storage Maxiumum LImit is 2048(2GB)
Memory Warning Limit is 1024(1GB)
Memory Maxiumum LImit is 2048(2GB)
(see screenshot)

The limits method parent_model_value calculates this:
 def parent_model_value(attr)
  value = $evm.parent[attr].to_i
  $evm.log(:info, "Quota Model #{attr}: #{value}") unless value.zero?
  if attr.ends_with?("storage") || attr.ends_with?(“memory”)
    value = value.megabytes
  end
  value
end

Besides the confusion of tag/model values, are the quota results incorrect?

Thanks,
Tina

Comment 6 Jeffrey Cutter 2016-11-10 21:39:38 UTC
Hi Tina,

The results being incorrect is what drew my attention to the problem.

In limits.rb, tag_value only gets run if $evm.root['quota_source_type'] is tenant.  So if quota_source_type is not tenant (in my case it was group) method parent_model_value gets used instead and treats both storage and memory as megabytes.

The diff from my changes which I included previously did resolve this issue for us.

Thanks,
-Jeff

Comment 7 Tina Fitzgerald 2016-12-06 16:59:57 UTC
Hi Jeff,

I spoke to Kevin Morey about this ticket and he pointed out that we
still have the old quota classes where the memory is in MB and storage
is in GB.
I didn't realize the old quota classes were still there and that's
probably a lot of the confusion.

We created a PR to remove the classes:
https://github.com/ManageIQ/manageiq/pull/12661

The new consolidated quota memory and quota values are in megabytes.

Let me know if you have any questions.

Thanks,
Tina


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