-
Notifications
You must be signed in to change notification settings - Fork 898
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
Chargeback for container images #10677
Conversation
@miq-bot add_label providers/containers, chargeback, wip |
@miq-bot assign zeari |
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
d8352d2
to
eadcc6e
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
21a6338
to
c9a89c6
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
c9a89c6
to
2373231
Compare
@@ -12,7 +12,6 @@ def disconnect_inv | |||
_log.info "Disconnecting Container definition [#{name}] id [#{id}]" | |||
self.container.try(:disconnect_inv) | |||
self.deleted_on = Time.now.utc | |||
self.container_group = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon3z In order to know which project a container belonged to, i need to keep this relationship and use
has_one :old_container_project, :through :container_group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this involved @moolitayer and @Fryguy in the past (they should be in the loop if they have time to look into this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me export this part to another PR and we can discuss it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -86,17 +86,20 @@ def get_rates(perf) | |||
@rates ||= {} | |||
@enterprise ||= MiqEnterprise.my_enterprise | |||
|
|||
state = perf.resource.vim_performance_state_for_ts(perf.timestamp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: See if we can make this happen only once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still bad performance. itll run vim_performance_state_for_ts
once per unique timestamp+image meaning if we have metrics for one week from 4 containers with different images then vim_performance_state_for_ts
will be called (7days) * (24 hours) * (4 number of different images) which is still a lot.
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
aa85f77
to
23371ed
Compare
@miq-bot add_label euwe/yes |
23371ed
to
126589d
Compare
bd1cf74
to
99c5d77
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
3bc013c
to
0e687a4
Compare
def self.report_name_field | ||
"project_name" | ||
def self.report_static_cols | ||
["project_name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think using %w(...)
is nicer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed where relevent.
0e687a4
to
e2c8539
Compare
@@ -102,4 +102,9 @@ def self.report_col_options | |||
def tags | |||
ContainerProject.includes(:tags).find_by_ems_ref(project_uid).try(:tags).to_a | |||
end | |||
|
|||
def get_rate_parents(perf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add this method to the base Chargeback
class and have it raise an error indicating that get_rate_parents
must be implemented in child class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -1030,20 +1031,27 @@ def set_record_vars(rpt) | |||
# Add in the chargeback static fields | |||
if Chargeback.db_is_chargeback?(rpt.db) # For chargeback, add in static fields | |||
rpt.cols = %w(start_date display_range) | |||
name_col = @edit[:new][:model].constantize.report_name_field | |||
tag_col = @edit[:new][:model].constantize.report_tag_field | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, move to Chargeback
modesl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
# get rates from image tags only | ||
[] | ||
end | ||
end # class Chargeback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comment to match class name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
:tag_names => "", | ||
:resource_name => @project.name, | ||
:resource_id => @project.id) | ||
state = VimPerformanceState.capture(@container) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use a factory for VimPerformanceState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im going to create another PR for this
Done
e2c8539
to
3462cd1
Compare
@gtanzillo All comments addressed |
Checked commits zeari/manageiq@3462cd1~...6cdb5ce with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/models/chargeback.rb
app/models/chargeback_container_image.rb
app/models/chargeback_vm.rb
app/views/report/_form_filter_chargeback.html.haml
spec/factories/vim_performance_state.rb
spec/models/chargeback_container_image_spec.rb
|
LGTM 👍 |
Chargeback for container images (cherry picked from commit 3b2860f)
Euwe Backport details: $ git log
commit 18cbc4604dc10b0f838333542b6e27d080b2a78b
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date: Mon Oct 10 16:17:29 2016 -0400
Merge pull request #10677 from zeari/chargeback_container_image
Chargeback for container images
(cherry picked from commit 3b2860f0878228c593575b4ce121c51b3d988c28) |
Chargeback based on the number of hours container images are running.
For this we need the following:
- [ ] Disconnect ContainerImages or keep them otherwise #10872we might not need thisChargebackRates
to specific image tags Added rate assigning by tags to container images #11015Container
metrics Add image tag names for Containers in vim performance state. #11016Full functionality depends on: #10120 #10671With just this patch, all image hours will cost the same.cc @simon3z