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

Add container groups\images statistics for container projects #10470

Merged
merged 1 commit into from
Oct 23, 2017

Conversation

zeari
Copy link

@zeari zeari commented Aug 15, 2016

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1487172
The container group calculation is relevant only for ems. This adjusts the calculation to be correct for projects too

@miq-bot add_label providers/containers
@yaacov Please review

@@ -4,7 +4,14 @@ def self.calculate_stat_columns(obj, timestamp)
return {} unless obj.respond_to?(:container_images)
Copy link
Author

Choose a reason for hiding this comment

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

Do we also want to separate these two conditions? (ie. we might have just :container_groups or just :container_images)

@zeari
Copy link
Author

zeari commented Aug 18, 2016

cc @simon3z

@simon3z
Copy link
Contributor

simon3z commented Sep 5, 2016

@zeari I have the feeling that we shouldn't check the object kind (e.g. obj.kind_of? ContainerProject). I have seen that @yaacov commented something around that. Is there a conclusion there?

@miq-bot assign zeari

@miq-bot miq-bot assigned zeari and unassigned simon3z Sep 5, 2016
if obj.respond_to?(:all_container_groups)
container_groups = obj.all_container_groups # Get disconnected entities as well
hash[:stat_container_group_create_rate] = container_groups.where(:ems_created_on => capture_interval).count
hash[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, style: two spaces instead of just one after the equal sign.

@simon3z
Copy link
Contributor

simon3z commented Sep 5, 2016

@yaacov @cben can you review?

hash[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count
end

if obj.respond_to?(:all_container_groups)
Copy link
Member

Choose a reason for hiding this comment

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

if obj.respond_to?(:container_images)?

hash[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count
end

if obj.respond_to?(:all_container_groups)
Copy link
Member

Choose a reason for hiding this comment

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

if obj.respond_to?(:container_images) ?

@yaacov
Copy link
Member

yaacov commented Sep 5, 2016

@zeari do we need the all_container_groups in app/models/container_project.rb ?

@zeari
Copy link
Author

zeari commented Sep 5, 2016

@zeari do we need the all_container_groups in app/models/container_project.rb

yes, Its a different query for ContainerManager and ContainerProject and they both have disconnected ContainerGroups.

@yaacov
Copy link
Member

yaacov commented Sep 5, 2016

yes, Its a different query for ContainerManager and ContainerProject and they both have disconnected ContainerGroups.

@zeari the question was why this function is missing from in this PR ?

@zeari
Copy link
Author

zeari commented Sep 5, 2016

@zeari the question was why this function is missing from in this PR ?

@yaacov It was added for chargeback in a different PR.

@yaacov
Copy link
Member

yaacov commented Sep 5, 2016

LGTM 👍

@simon3z
Copy link
Contributor

simon3z commented Sep 5, 2016

The container group calculation was relevant only for ems.
Now its relevant for all entities.

@zeari is this a part of some other larger work or is this standalone? (I understand what it does, but why do we need it?)

@zeari
Copy link
Author

zeari commented Sep 5, 2016

@simon3z I was fixing metrics for ContainerProject and noticed this code was odd.

Edit:
Previously the statistics were calculated wrong -
with ems_id == id for all entities that respond_to?(:container_groups, :container_images)

@simon3z
Copy link
Contributor

simon3z commented Sep 6, 2016

@zeari should you label this as a bug? Should we care about fixing this in darga?

@zeari
Copy link
Author

zeari commented Sep 6, 2016

Not really, we dont currently use creation statistics for anything other than ems

@miq-bot add_label darga/no

@zeari
Copy link
Author

zeari commented Sep 6, 2016

@miq-bot add_label bug

@@ -9,7 +9,6 @@ class ContainerProject < ApplicationRecord
has_many :container_replicators
has_many :container_services
has_many :containers, :through => :container_groups
has_many :containers, :through => :container_groups

Choose a reason for hiding this comment

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

oh my

Copy link
Contributor

Choose a reason for hiding this comment

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

@zeari @moolitayer do we want to split this fix out and get it merged right away?

Choose a reason for hiding this comment

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

@zeari if you need review on that one, I will try to merge fast.

container_groups = ContainerGroup.where(:ems_id => obj.id).or(ContainerGroup.where(:old_ems_id => obj.id))
stats = {}

if obj.respond_to?(:all_container_groups)

Choose a reason for hiding this comment

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

looks like this fixes a bug (previously stat_container_group_delete_rate for ems were always 0)

stats[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count
end

if obj.respond_to?(:container_images)

Choose a reason for hiding this comment

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

I see this was mentioned before, but shouldn't we have something like all_container_images in container_project and use that here? otherwise we might miss images that were registered and then deleted?

Choose a reason for hiding this comment

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

Ah I read you wrote it's in another PR. So this should be updated after adding the method? Maybe it's worth a TODO so we don't forget?

Copy link
Author

Choose a reason for hiding this comment

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

ah, it wasnt relevant when i opened the PR but it is now. Adding.

@simon3z
Copy link
Contributor

simon3z commented Aug 24, 2017

@moolitayer @zeari do we need a BZ for fine?

@zeari
Copy link
Author

zeari commented Aug 24, 2017

@moolitayer @zeari do we need a BZ for fine?

@simon3z i dont think so. it currently works correctly for ems and ManageIQ/manageiq-ui-classic#1527 is for next version.

@simon3z
Copy link
Contributor

simon3z commented Aug 24, 2017

@simon3z i dont think so. it currently works correctly for ems and ManageIQ/manageiq-ui-classic#1527 is for next version.

@zeari @moolitayer mentioned a bug related to stat_container_group_delete_rate, isn't that affecting fine as well?

@zeari
Copy link
Author

zeari commented Aug 27, 2017

@moolitayer does this need to be in fine? I think we will need a fine specific PR since this is based on the archival change from :ems_id => nil to active => true

@zeari
Copy link
Author

zeari commented Aug 27, 2017

@moolitayer @simon3z @cben stat_container_image_registration_rate for projects could be how many images that were never in use before in this project, are first used in this hour. but we dont use this information anywhere for projects.

ContainerProject.find(18).all_container_groups.joins(:containers).joins(:container_images).group('container_images.id').select('container_images.id').having('min(container_groups.ems_created_on) > ? and min(container_groups.ems_created_on) < ?', 1.hour.ago, Time.now).collect(&:attributes).count

@moolitayer
Copy link

@moolitayer does this need to be in fine? I think we will need a fine specific PR since this is based on the archival change from :ems_id => nil to active => true

Is this based on a bz or is it for a new feature(e.g a dashboard showing this info)?
So in fine we had these states attached to container_projects but we weren't calculating them correctly?
(we are calculating them from the quite some time but I haven't checked if we always calculated it for projects too)

I think fixing fine is a good idea. We will need a bz to backport.

@simon3z
Copy link
Contributor

simon3z commented Aug 28, 2017

I think fixing fine is a good idea. We will need a bz to backport.

@zeari @moolitayer please let's open one. If you're unsure you can have QE to try and reproduce the issue (so then they'll also know how to verify that it's fixed once delivered).

@zeari
Copy link
Author

zeari commented Aug 31, 2017

@miq-bot add_label fine/yes

@zeari
Copy link
Author

zeari commented Aug 31, 2017

This requires a fine-specific PR

@miq-bot
Copy link
Member

miq-bot commented Aug 31, 2017

Checked commit zeari@1613f75 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@zeari
Copy link
Author

zeari commented Sep 5, 2017

ping @moolitayer @simon3z BZ is in place and comments addressed

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@zeari
Copy link
Author

zeari commented Oct 15, 2017

ping @simon3z

Copy link
Contributor

@simon3z simon3z left a comment

Choose a reason for hiding this comment

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

👍

@simon3z
Copy link
Contributor

simon3z commented Oct 20, 2017

@miq-bot assign blomquisg

@miq-bot miq-bot assigned blomquisg and unassigned zeari Oct 20, 2017
@blomquisg blomquisg merged commit 35616a5 into ManageIQ:master Oct 23, 2017
@blomquisg blomquisg added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 23, 2017
@simaishi
Copy link
Contributor

Backported to Fine via #16345

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.

8 participants