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

Charge for container limits in ChargebackContainerImage #15616

Merged
merged 1 commit into from
Oct 30, 2017

Conversation

zeari
Copy link

@zeari zeari commented Jul 20, 2017

BZ:https://bugzilla.redhat.com/show_bug.cgi?id=1452799
Charge for container cpu and memory limits as the allocated cpu and memory in chargeback reports.
This makes the allocated columns available for "Chargeback for container images" reports.
screencapture-localhost-3000-chargeback-explorer-1505481900971
screencapture-localhost-3000-report-explorer-1505482578010

@lpichler Please review
cc @simon3z

@miq-bot add_label wip, compute/containers

@miq-bot
Copy link
Member

miq-bot commented Jul 20, 2017

@zeari Cannot apply the following label because they are not recognized: compute/containers

@miq-bot miq-bot changed the title charge for container limits in ChargebackContainerImage [WIP] charge for container limits in ChargebackContainerImage Jul 20, 2017
@miq-bot miq-bot added the wip label Jul 20, 2017
@zeari
Copy link
Author

zeari commented Jul 20, 2017

@miq-bot add_label providers/containers

@simon3z
Copy link
Contributor

simon3z commented Jul 21, 2017

@zeari WRT the first screenshot it seems that we want to reuse the already present "Allocated CPU Count" and "Allocated Memory" rate fields (instead of adding the new "Limit" ones).

@@ -22,6 +22,10 @@ def avg(metric)
metric_sum / consumed_hours_in_interval
end

def limit_value(metric)
resource.try("limit_" + metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

will the report be failing if there will be nil ?

Copy link
Author

@zeari zeari Jul 21, 2017

Choose a reason for hiding this comment

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

No, nil would just be counted as zero

@zeari zeari force-pushed the chargeback_by_limit branch 2 times, most recently from fd0e8e5 to bd5935f Compare August 9, 2017 12:46
@zeari zeari force-pushed the chargeback_by_limit branch from bd5935f to c4e7a13 Compare August 9, 2017 12:54
@zeari
Copy link
Author

zeari commented Aug 9, 2017

@lpichler Please re-review. Instead of adding new columns for container limits, I leverage the method_for_allocated_metrics option to re-use the existing allocated cpu\memory columns.
its the most none-hacky way i found to integrate this feature and its similar to current_value in consumption_without_rollups.rb

@simon3z @Loicavenel Notice this charges for allocated resources only when a metric for a time period is available.
this is in contrary to disregarding collected metrics and just charging a constant 24 * container.limit_cpu\memory for each day.

@zeari
Copy link
Author

zeari commented Aug 17, 2017

Notice this charges for allocated resources only when a metric for a time period is available.
this is in contrary to disregarding collected metrics and just charging a constant 24 * container.limit_cpu\memory for each day.

So fixed compute works this way and having just allocated costs work the other way is a bad idea.
I think this is the way to go.

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] charge for container limits in ChargebackContainerImage charge for container limits in ChargebackContainerImage Aug 17, 2017
@miq-bot miq-bot removed the wip label Aug 17, 2017
@zeari zeari changed the title charge for container limits in ChargebackContainerImage Charge for container limits in ChargebackContainerImage Aug 17, 2017
@zeari zeari force-pushed the chargeback_by_limit branch 3 times, most recently from 788ac81 to d1723a3 Compare August 17, 2017 14:53
@lpichler
Copy link
Contributor

@miq-bot assign @lpichler

@miq-bot miq-bot assigned lpichler and unassigned simon3z Aug 21, 2017
Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

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

@zeari you are adding allocated metrics(limits) for memory and CPU.
we added method_for_allocated_metrics for changing a way how allocated metrics are calculated.
So I am ok with using this for those reasons.

Am I right that all allocated metrics for container comes from current state?

the only what I am suggesting is to change terminology
some thing like 'current_value',... method for allocated could be called current_value.

Also we have this option in UI in filter tab ManageIQ/manageiq-ui-classic#1738. So I think we need to remove it for the container.

thanks!

@zeari zeari force-pushed the chargeback_by_limit branch from d1723a3 to ae58c26 Compare August 28, 2017 13:48
return consumption.send(options.method_for_allocated_metrics, metric) if allocated?
return consumption.avg(metric) if used?
return 0 if consumption.none?(metric)
Copy link
Author

Choose a reason for hiding this comment

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

@lpichler im not sure if i should remove this line entirely. consumption.none?(metric) could be true for a container for one of the allocated fields while the actual field is calculated differently through current_value

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -24,6 +24,8 @@ class Container < ApplicationRecord
include EventMixin
include Metric::CiMixin

delegate :created_on, :to => :container_group

Copy link
Author

Choose a reason for hiding this comment

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

This solved a CB bug. I can move this to a different PR.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@zeari it would be preferable to have this in another PR, easier to track and merge (hopefully?).

Copy link
Author

Choose a reason for hiding this comment

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

sure

@zeari zeari force-pushed the chargeback_by_limit branch 3 times, most recently from f560d2e to e55995f Compare August 31, 2017 10:54
@zeari zeari force-pushed the chargeback_by_limit branch 2 times, most recently from 429f2eb to f1e0252 Compare October 3, 2017 23:02
@zeari zeari force-pushed the chargeback_by_limit branch from f1e0252 to dcb23a5 Compare October 15, 2017 08:01
@zeari zeari force-pushed the chargeback_by_limit branch 2 times, most recently from a5ea21c to ebfdb2f Compare October 15, 2017 09:52
@zeari
Copy link
Author

zeari commented Oct 15, 2017

do we need migration for existing rates when we are adding new metric allocated cpu cores?

The new 'allocated cores' rate detail should be in the default and default container image rate. When someone upgrades dont they run rake db:seed to get new fixtures?

@Loicavenel
Copy link

@zeari they run rake db:migrate

@zeari
Copy link
Author

zeari commented Oct 16, 2017

@zeari they run rake db:migrate

I think I get the point @lpichler. That wouldnt add the new Allocated CPU Cores rate row to existing custom rates

@Loicavenel
Copy link

@zeari @lpichler it will not even add it with no value? the only option will be to delete and re-create it?

@miq-bot
Copy link
Member

miq-bot commented Oct 20, 2017

This pull request is not mergeable. Please rebase and repush.

Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

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

👍 @gtanzillo

@miq-bot
Copy link
Member

miq-bot commented Oct 27, 2017

This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the chargeback_by_limit branch from 82305c7 to 9767bea Compare October 29, 2017 10:21
@miq-bot
Copy link
Member

miq-bot commented Oct 29, 2017

Checked commit zeari@9767bea with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
9 files checked, 1 offense detected

spec/factories/chargeback_rate_detail.rb

@zeari
Copy link
Author

zeari commented Oct 30, 2017

@gtanzillo @lpichler please merge

Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

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

@blomquisg re-approved

@gtanzillo gtanzillo added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 30, 2017
@gtanzillo gtanzillo merged commit 9252900 into ManageIQ:master Oct 30, 2017
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.

6 participants