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

Support alerts on container nodes #13812

Merged
merged 1 commit into from
Feb 14, 2017
Merged

Conversation

moolitayer
Copy link

@moolitayer moolitayer commented Feb 8, 2017

Add the ability to define miq alerts on container nodes.
The usual flow miq alert statuses are created: an ems event is collected and then evaluated for an alert[1]
Currently only ems events from Hawkular are evaluated for alerts on container nodes.
Since we are offloading the logic of triggering to Hawkular every ems event already means a miq_alert_status needs to be created (if a miq alert has been defined)

Currently we only support defining the miq alert on all the nodes in the enterprise since that is what we would use (actual target object is found based on metadata on the incoming event)

Extracted from #12773

[1]

@event.policy("src_vm", @event.event_type) if MiqAlert.event_alertable?(@event.event_type)

@moolitayer
Copy link
Author

@simon3z @durandom please review

@moolitayer
Copy link
Author

@cben please review

@moolitayer
Copy link
Author

@miq-bot add_label enhancement, providers/containers

@moolitayer
Copy link
Author

@simon3z please review

@moolitayer
Copy link
Author

@simon3z @cben please review

@simon3z
Copy link
Contributor

simon3z commented Feb 9, 2017

@cben can you review this first?

@@ -196,6 +196,7 @@ def get_target(target_type)
target_type = "src_vm_or_template" if target_type == "src_vm"
target_type = "dest_vm_or_template" if target_type == "dest_vm"
target_type = "middleware_server" if event.event_type == "hawkular_alert"
target_type = "container_node" if event.event_type == "datawarehouse_event"
Copy link
Author

Choose a reason for hiding this comment

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

these need to be renamed to datawarehouse_alert as @lucasponce pointed here

Copy link
Contributor

Choose a reason for hiding this comment

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

Sufficient now but you need a plan for deriving target_type when you'll have more entities beside container_node...

Copy link
Author

Choose a reason for hiding this comment

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

Yes though of that but I'm not sure yet

@moolitayer
Copy link
Author

@cben please review

else
User.super_admin.tap { |u| u.current_group = Tenant.root_tenant.default_miq_group }
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I wish we could stop copy-pasting this black magic, but that would take someone who understands it to suggest an appropriate place...

Copy link
Author

Choose a reason for hiding this comment

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

Turns out we can 😄 since TenantIdentityMixin is already included here 👍

def evaluate_alert(_alert_id, _event)
# currently only EmsEvents from hawkular are tested for node alerts,
# and these should automaticaly be translated to alerts.
true
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine for now, because we don't currently support regular MiqExpression-evaluating alerts on container entities.
But would it be hard to check something on the event to confirm it's a hawkular alerting event, just in case?

Copy link
Author

Choose a reason for hiding this comment

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

I plan to add something that will propegate to this point in #12773 then I will be able to add a check

@@ -196,6 +196,7 @@ def get_target(target_type)
target_type = "src_vm_or_template" if target_type == "src_vm"
target_type = "dest_vm_or_template" if target_type == "dest_vm"
target_type = "middleware_server" if event.event_type == "hawkular_alert"
target_type = "container_node" if event.event_type == "datawarehouse_event"
Copy link
Contributor

Choose a reason for hiding this comment

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

Sufficient now but you need a plan for deriving target_type when you'll have more entities beside container_node...

@@ -434,7 +435,9 @@ def self.automate_expressions
:options => [
{:name => :mw_operator, :description => _("Operator"), :values => [">", ">=", "<", "<=", "="]},
{:name => :value_mw_garbage_collector, :description => _("Duration Per Minute (ms)"), :numeric => true}
]}
]},
{:name => "hwk_generic", :description => _("All hawkular alerts"), :db => ["ContainerNode"], :responds_to_events => "datawarehouse_event",
Copy link
Contributor

Choose a reason for hiding this comment

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

"All hawkular alerts" may need more context given the existing middleware conditions above?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe "All Datawarehouse Events" ?

@moolitayer
Copy link
Author

moolitayer commented Feb 12, 2017

Thanks @cben 🎉

@moolitayer
Copy link
Author

@cben @simon3z please review

@simon3z
Copy link
Contributor

simon3z commented Feb 13, 2017

@cben can you review/ack this?

@cben
Copy link
Contributor

cben commented Feb 13, 2017

LGTM

@simon3z
Copy link
Contributor

simon3z commented Feb 13, 2017

@moolitayer @cben anything to test?

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

I really like the size of the PR 👍

@@ -196,6 +196,7 @@ def get_target(target_type)
target_type = "src_vm_or_template" if target_type == "src_vm"
target_type = "dest_vm_or_template" if target_type == "dest_vm"
target_type = "middleware_server" if event.event_type == "hawkular_alert"
target_type = "container_node" if event.event_type == "datawarehouse_alert"
Copy link
Member

Choose a reason for hiding this comment

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

I already dislike the one line above, where it does implicitly connects hawkular to middleware_server
Is it possible to switch on something else than datawarehose_alert ? Maybe not switch on event.event_type but on some other meta data?

Copy link
Author

Choose a reason for hiding this comment

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

This as well as the logic in container_node.evaluate_alert would be much, much easier to improve in #12773 when this is merged. Can we try to do it at that iteration please?

Copy link
Member

Choose a reason for hiding this comment

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

ok, I guess you are the only provider that sends datawarehouse_alert anyway

@@ -434,7 +435,9 @@ def self.automate_expressions
:options => [
{:name => :mw_operator, :description => _("Operator"), :values => [">", ">=", "<", "<=", "="]},
{:name => :value_mw_garbage_collector, :description => _("Duration Per Minute (ms)"), :numeric => true}
]}
]},
{:name => "hwk_generic", :description => _("All Datawarehouse alerts"), :db => ["ContainerNode"], :responds_to_events => "datawarehouse_alert",
Copy link
Member

@durandom durandom Feb 13, 2017

Choose a reason for hiding this comment

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

could this be dwh_generic ?

@miq-bot
Copy link
Member

miq-bot commented Feb 13, 2017

Checked commit moolitayer@92cc359 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. ⭐

@moolitayer
Copy link
Author

@moolitayer @cben anything to test?

I'm adding tests for the entire flow in the event collection patch
Some of this code is tested here

@moolitayer
Copy link
Author

moolitayer commented Feb 13, 2017

Integration failure seems unrelated

    Failure/Error: cv1 = FactoryGirl.create(:cloud_volume_amazon, :attachments => [disk])
     
     NameError:
       uninitialized constant ManageIQ::Providers::Amazon::CloudManager::CloudVolume
     # ./spec/models/cloud_volume_spec.rb:4:in `block (2 levels) in <top (required)>'

...
    rspec ./spec/models/cloud_volume_spec.rb:2 # CloudVolume .available

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

lgtm

once master #13886 is merged, you can re-kick the CI?

@miq-bot assign @blomquisg

@@ -196,6 +196,7 @@ def get_target(target_type)
target_type = "src_vm_or_template" if target_type == "src_vm"
target_type = "dest_vm_or_template" if target_type == "dest_vm"
target_type = "middleware_server" if event.event_type == "hawkular_alert"
target_type = "container_node" if event.event_type == "datawarehouse_alert"
Copy link
Member

Choose a reason for hiding this comment

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

ok, I guess you are the only provider that sends datawarehouse_alert anyway

@miq-bot miq-bot assigned durandom and unassigned simon3z Feb 13, 2017
@moolitayer moolitayer closed this Feb 13, 2017
@moolitayer moolitayer reopened this Feb 13, 2017
@durandom
Copy link
Member

@miq-bot assign @blomquisg
@blomquisg please merge

@miq-bot miq-bot assigned blomquisg and unassigned durandom Feb 14, 2017
@blomquisg blomquisg merged commit 7506b85 into ManageIQ:master Feb 14, 2017
@blomquisg blomquisg added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 14, 2017
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