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

Conditionally update alert repeat times #2714

Merged
merged 1 commit into from
Feb 2, 2018

Conversation

moolitayer
Copy link

@moolitayer moolitayer commented Nov 13, 2017

commit ea2f7ec[1] removed setting of
'notification frequency' after changing what to evaluate. Prometheus
alerts relayed on that behavior and it has become impossible to create
them. alert_default_repeat_time sets the value to zero and the field
is then hidden[2]. Since there is a model validation for the zero value
the alerts can't be created. A similar behavior for "hourly alerts"
changed - their default notification frequency should change to 1 Hour.

[1] #2601
[2] :

@moolitayer
Copy link
Author

@miq-bot add_label bug
@miq-bot add_label gaprindashvili/no

@moolitayer
Copy link
Author

@ZitaNemeckova @mzazrivec please review

@moolitayer
Copy link
Author

@ZitaNemeckova @mzazrivec bump

@ZitaNemeckova
Copy link
Contributor

@moolitayer Is it possible to call alert_default_repeat_time only for alerts that really need it? That way #2147 would be resolved without crushing Prometheus alerts.

@moolitayer
Copy link
Author

@ZitaNemeckova that can work by only resetting notification frequency for prometheus alerts and hourly alerts. That would mean that if someone has an hourly alert and then changes it to be based on a different event they would still have a 60 min notification frequency - I can live with that. Does it make sense?

cc @abonas

@martinpovolny
Copy link
Member

@moolitayer : are we going to merge this one or drop it? Thx!

@moolitayer moolitayer changed the title Revert "Remove dependency of two fields in Alerts" Conditionally update alert repeat times Dec 24, 2017
@moolitayer
Copy link
Author

@martinpovolny @ZitaNemeckova ready, trying to keep #2601 while not removing behavior we want to keep

@moolitayer
Copy link
Author

ping @martinpovolny

@@ -368,6 +369,12 @@ def alert_default_repeat_time
end
end

def apply_default_repeat_time?
(@edit[:new][:expression][:eval_method] && @edit[:new][:expression][:eval_method] == "hourly_performance") ||
Copy link
Member

Choose a reason for hiding this comment

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

can you write it to using early return instead, e.g. something like:

def method
  event = @edit[:new]
  return true if event[:exp_event] == '_hourly_timer_'
  return false if event[:eval_method].nil?
  event[:eval_method] == /hourly_performance|dwh_generic/
end

Also - missing tests.

@moolitayer moolitayer force-pushed the fix_prometheus_alerts branch 2 times, most recently from 52c62ca to 55cb256 Compare January 11, 2018 10:38
commit ea2f7ec[1] removed setting of
'notification frequency' after changing what to evaluate. Prometheus
alerts relayed on that behavior and it has become impossible to create
them. alert_default_repeat_time sets the value to zero and the field.
is then hidden[2]. Since there is a model validation for the zero value
the alerts can't be created. A similar behavior for "hourly alerts"
changed - their default notification frequency should change to zero.

[1] ManageIQ#2601
[2] https://github.com/ManageIQ/manageiq-ui-classic/blob/983bd1d690cd684d8e0f730f2e170fc2e3d69c7f/app/views/miq_policy/_alert_details.html.haml#L131
@miq-bot
Copy link
Member

miq-bot commented Jan 11, 2018

Checked commit moolitayer@17a477f with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@moolitayer
Copy link
Author

moolitayer commented Jan 11, 2018

I was getting different TEST_SUITE=spec failures every time, what I remember is

./spec/controllers/ops_controller/settings/label_tag_mapping_spec.rb
/spec/controllers/report_controller_spec.rb:1380

Unrelated TEST_SUITE=javascript would not run several times

@moolitayer
Copy link
Author

@ohadlevy updated, please take a look

@moolitayer
Copy link
Author

@ohadlevy PTAL

@moolitayer
Copy link
Author

@ohadlevy @martinpovolny ping

@ohadlevy
Copy link
Member

visual code inspection seems OK, thanks @moolitayer

@moolitayer
Copy link
Author

@miq-bot assign @martinpovolny

@martinpovolny martinpovolny merged commit acc8b8a into ManageIQ:master Feb 2, 2018
@martinpovolny martinpovolny added this to the Sprint 79 Ending Feb 12, 2018 milestone Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants