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

Chargeback for container images #10677

Merged
merged 2 commits into from
Oct 10, 2016

Conversation

zeari
Copy link

@zeari zeari commented Aug 22, 2016

Chargeback based on the number of hours container images are running.
For this we need the following:
- [ ] Disconnect ContainerImages or keep them otherwise #10872 we might not need this

screencapture-localhost-3000-report-explorer-1471901848587
screencapture-localhost-3000-report-explorer-1471901822288

Full functionality depends on: #10120 #10671
With just this patch, all image hours will cost the same.
cc @simon3z

@zeari
Copy link
Author

zeari commented Aug 22, 2016

@miq-bot add_label providers/containers, chargeback, wip

@simon3z
Copy link
Contributor

simon3z commented Aug 23, 2016

@miq-bot assign zeari

@miq-bot
Copy link
Member

miq-bot commented Aug 23, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Sep 7, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the chargeback_container_image branch 2 times, most recently from 21a6338 to c9a89c6 Compare September 12, 2016 09:59
@miq-bot
Copy link
Member

miq-bot commented Sep 13, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@@ -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
Copy link
Author

@zeari zeari Sep 22, 2016

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

Copy link
Contributor

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).

Copy link
Author

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.

Copy link
Author

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)
Copy link
Author

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

Copy link
Author

@zeari zeari Sep 26, 2016

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.

@miq-bot
Copy link
Member

miq-bot commented Sep 22, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the chargeback_container_image branch 4 times, most recently from aa85f77 to 23371ed Compare September 26, 2016 14:54
@zeari
Copy link
Author

zeari commented Sep 26, 2016

@miq-bot add_label euwe/yes

@zeari zeari changed the title [WIP] Chargeback for container images Chargeback for container images Sep 26, 2016
@zeari zeari force-pushed the chargeback_container_image branch 8 times, most recently from bd1cf74 to 99c5d77 Compare September 29, 2016 13:21
@miq-bot
Copy link
Member

miq-bot commented Oct 4, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the chargeback_container_image branch 2 times, most recently from 3bc013c to 0e687a4 Compare October 6, 2016 11:07
def self.report_name_field
"project_name"
def self.report_static_cols
["project_name"]
Copy link
Member

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 ?

Copy link
Author

Choose a reason for hiding this comment

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

Changed where relevent.

@zeari zeari force-pushed the chargeback_container_image branch from 0e687a4 to e2c8539 Compare October 6, 2016 11:34
@@ -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)
Copy link
Member

@gtanzillo gtanzillo Oct 6, 2016

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.

Copy link
Author

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

Copy link
Member

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.

Copy link
Author

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
Copy link
Member

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

Copy link
Author

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)
Copy link
Member

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

Copy link
Author

@zeari zeari Oct 6, 2016

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

@zeari zeari force-pushed the chargeback_container_image branch from e2c8539 to 3462cd1 Compare October 6, 2016 15:51
@zeari
Copy link
Author

zeari commented Oct 6, 2016

@gtanzillo All comments addressed

@miq-bot
Copy link
Member

miq-bot commented Oct 6, 2016

Checked commits zeari/manageiq@3462cd1~...6cdb5ce with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
9 files checked, 29 offenses detected

app/models/chargeback.rb

app/models/chargeback_container_image.rb

app/models/chargeback_vm.rb

app/views/report/_form_filter_chargeback.html.haml

  • ⚠️ - Line 113 - Prefer to_s over string interpolation.
  • ⚠️ - Line 113 - Prefer to_s over string interpolation.
  • ⚠️ - Line 114 - Prefer to_s over string interpolation.
  • ⚠️ - Line 115 - Prefer to_s over string interpolation.

spec/factories/vim_performance_state.rb

spec/models/chargeback_container_image_spec.rb

@gtanzillo
Copy link
Member

LGTM 👍

@gtanzillo gtanzillo added this to the Sprint 48 Ending Oct 24, 2016 milestone Oct 10, 2016
@gtanzillo gtanzillo merged commit 3b2860f into ManageIQ:master Oct 10, 2016
chessbyte pushed a commit that referenced this pull request Oct 13, 2016
Chargeback for container images
(cherry picked from commit 3b2860f)
@chessbyte
Copy link
Member

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)

@zeari zeari deleted the chargeback_container_image branch August 24, 2017 07:37
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