-
Notifications
You must be signed in to change notification settings - Fork 900
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
Conversation
0cd30de
to
cc9cda0
Compare
app/models/metric/statistic.rb
Outdated
@@ -4,7 +4,14 @@ def self.calculate_stat_columns(obj, timestamp) | |||
return {} unless obj.respond_to?(:container_images) |
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.
Do we also want to separate these two conditions? (ie. we might have just :container_groups
or just :container_images
)
cc @simon3z |
cc9cda0
to
7f23186
Compare
app/models/metric/statistic.rb
Outdated
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 |
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.
Minor, style: two spaces instead of just one after the equal sign.
7f23186
to
2f98e41
Compare
app/models/metric/statistic.rb
Outdated
hash[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count | ||
end | ||
|
||
if obj.respond_to?(:all_container_groups) |
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.
if obj.respond_to?(:container_images)
?
2f98e41
to
b523494
Compare
app/models/metric/statistic.rb
Outdated
hash[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count | ||
end | ||
|
||
if obj.respond_to?(:all_container_groups) |
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.
if obj.respond_to?(:container_images)
?
@zeari do we need the |
b523494
to
7476e2c
Compare
yes, Its a different query for |
@zeari the question was why this function is missing from in this PR ? |
LGTM 👍 |
@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?) |
@simon3z I was fixing metrics for Edit: |
@zeari should you label this as a bug? Should we care about fixing this in darga? |
Not really, we dont currently use creation statistics for anything other than ems @miq-bot add_label darga/no |
@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 |
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.
oh my
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.
@zeari @moolitayer do we want to split this fix out and get it merged right away?
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.
@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) |
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.
looks like this fixes a bug (previously stat_container_group_delete_rate for ems were always 0)
app/models/metric/statistic.rb
Outdated
stats[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count | ||
end | ||
|
||
if obj.respond_to?(:container_images) |
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 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?
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.
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?
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.
ah, it wasnt relevant when i opened the PR but it is now. Adding.
@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. |
@zeari @moolitayer mentioned a bug related to |
@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 |
@moolitayer @simon3z @cben 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 |
Is this based on a bz or is it for a new feature(e.g a dashboard showing this info)? 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). |
@miq-bot add_label fine/yes |
5475b07
to
1613f75
Compare
This requires a fine-specific PR |
Checked commit zeari@1613f75 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
ping @moolitayer @simon3z BZ is in place and comments addressed |
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.
LGTM 👍
ping @simon3z |
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.
👍
@miq-bot assign blomquisg |
Backported to Fine via #16345 |
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