-
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
Miq Alert Status model changes for resolved alerts #14295
Conversation
@miq-bot add_label enhancement, providers/containers |
@moolitayer it seems that there are Travis failures to fix. |
7d45443
to
1b6821a
Compare
class AddAlertEmsRef < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :miq_alert_statuses, :ems_ref, :string | ||
add_index :miq_alert_statuses, :ems_ref |
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.
@kbrock I'm pretty sure this isn't the index I need, here is the query using it:
https://github.com/moolitayer/manageiq/blob/f423f61dbc0485eee72f2bb153ce1303e70a96dd/app/models/miq_alert.rb#L217
An explain of that query:
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------
Limit (cost=0.00..1.04 rows=1 width=239)
-> Seq Scan on miq_alert_statuses (cost=0.00..1.04 rows=1 width=239)
Filter: ((miq_alert_id = '1000000000028'::bigint) AND ((resource_type)::text = 'ContainerNode'::text) AND (resource_id = '1000000000001'::bigint) AND ((ems_ref)::text = 'ops-example-1489487734309-58f1aa
1c-dafe-4285-bbae-ec7a788de50d'::text))
(3 rows)
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.
@kbrock I think a good solution might be to have an index on event_ems_ref and remove the resource part from the query. WDYT?
@simon3z please review, this is the most pressing PR for me ATM, as many others depend on it. |
@simon3z This is the most urgent PR for me ATM, most others are dependent on it |
@moolitayer then I think you should seek some code reviews; who is familiar with this part? |
The PR itself is straightforward 👍 but I'd like to better understand what
Assuming that's right: Having several records with same |
1b6821a
to
5ef9392
Compare
Checked commits moolitayer/manageiq@6851d68~...5ef9392 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@cben a nicer solution model wise would be to link the MAS to the EmsEvent that caused it and use that to do the join. Unfortunately that would produce complex queries on the join for an incoming EmsEvent. I chose this way for practicality. I've changed the name to event_ems_ref as suggested |
@cben please review |
LGTM 👍 @miq-bot assign Fryguy |
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 great!
Can feel the performance improvements already ;)
Think the only thing missing here is the data migration
class MiqAlertStatus < ApplicationRecord | ||
SEVERITY_LEVELS = %w(error warning info).freeze | ||
|
||
has_ancestry |
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.
yay!
@@ -0,0 +1,5 @@ | |||
class AddResolvedToAlerts < ActiveRecord::Migration[5.0] | |||
def change | |||
add_column :miq_alert_statuses, :resolved, :boolean |
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.
think we want to populate in a data migration
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.
We do not need that since resolved alerts are only used in the datawarehouse provider which is prototype and hidden in the product. Also resolved alerts are not yet collected (that pr is being reviewed as well #14299)
class AddAlertEmsRef < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :miq_alert_statuses, :event_ems_ref, :string | ||
add_index :miq_alert_statuses, :event_ems_ref |
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.
Is this ems_ref related to the manageiq events table at all? If not, then this name might be confusing.
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.
Or I can just read back in the thread 😄
It's worse than weird, it's a potential problem. In the future we are considering making ems_id, ems_ref a unique index to help with some refresh issues, so that will be a problem in the future if there are duplicates. |
the intention was to link an open alert with a resolved one and figure out using ancestry which alerts to show in the screen (only opening ones, the have no resolving mas). It became apparent it would be more straight forward to represent that using one MAS with a new field(see next commit) and that would also make retrival more performant (save an N+1 issue).