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

Don't charge hours before Vm/Container/Project was created #13373

Merged
merged 2 commits into from
Jan 10, 2017

Conversation

isimluk
Copy link
Member

@isimluk isimluk commented Jan 6, 2017

What

When calculating average consumption (like Mhz) we divide consumption by number of hours in the interval. However, when VM gets created in the middle of the month, we should divide only by number of hours that the resource lived. Similarly, we should charge the consumption only for the hours that the resource existed.

Why

This becomes important for SCVMM. We charge for SCVMM without metric rollups. Hence, this case have higher chances to occur with SCVMM chargebacks. (Although it affects rollup-based chargebacks as well).

Note

This pr builds on top of #13134.

@miq-bot add_label chargeback, bug
@miq-bot assign @gtanzillo

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

Nice implementation of consumed_hours_in_interval 👍

# 2) We cannot charge for future hours (i.e. weekly report on Monday, should charge just monday)
@consumed_hours_in_interval ||= begin
consuption_start = [@start_time, resource.try(:created_on)].compact.max
consumption_end = [Time.current, @end_time].min
Copy link
Member

Choose a reason for hiding this comment

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

Should this use Time.current.utc to ensure the time is not in the local time zone?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about this for a while. It seems the TZ does not matter in this case.

The consumption_end is just used for substraction.

@miq-bot
Copy link
Member

miq-bot commented Jan 10, 2017

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

We are gonna change code to charge only for consumption since the
resource creation time. First, we need to make sure all our test subject
have proper created_on timestamp.
@isimluk isimluk changed the title [WIP] Don't charge hours before Vm/Container/Project was created Don't charge hours before Vm/Container/Project was created Jan 10, 2017
@isimluk
Copy link
Member Author

isimluk commented Jan 10, 2017

@miq-bot remove_label wip

@miq-bot
Copy link
Member

miq-bot commented Jan 10, 2017

Checked commits isimluk/manageiq@e2d0561~...1317470 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
6 files checked, 0 offenses detected
Everything looks good. 🍰

@gtanzillo gtanzillo added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 10, 2017
@gtanzillo gtanzillo merged commit 9060319 into ManageIQ:master Jan 10, 2017
@simaishi
Copy link
Contributor

Backported to Euwe via #13554

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.

4 participants