-
Notifications
You must be signed in to change notification settings - Fork 897
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
Notify users of killing workers when exceed memory #17673
Conversation
544b88e
to
f861c69
Compare
5bd0b97
to
6bfd073
Compare
cd6c4f4
to
a32c1fd
Compare
app/models/notification_type.rb
Outdated
end | ||
end | ||
|
||
# this disables notifications, but allows the notification to still exist | ||
# this notification template can be used for emails | ||
def none? |
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 don't really like the name. At first glance it feels like Enumerable#none?
which is completely unrelated.
Maybe has_audience?
or even something like enabled?
(or the negative of either of those)?
If we're not raising the notification to the user (audience type "none") why are we creating it? Is is just for the string interpolation based on type? That's only there for translations. Is there no other way to get this particular string translated for the email? I'm okay with this approach if there's a reason behind it, but I don't think I understand that reason just yet. |
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.
Two minor comments. @gtanzillo Do you have thoughts on the Notification side of things?
app/models/notification.rb
Outdated
Notification.create(:notification_type => type, | ||
:options => event.full_data, | ||
:subject_id => event.target_id, | ||
:subject_type => event.target_type) |
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 subject id
and type
need to be broken out or can it remain as it was before :subject => event.target
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 liked the idea of not looking up the target object, but reverting back to original is fine
app/models/notification.rb
Outdated
@@ -41,6 +45,12 @@ def seen_by_all_recipients? | |||
notification_recipients.unseen.empty? | |||
end | |||
|
|||
def self.notification_text(event_type, full_data) | |||
return unless NotificationType.names.include?(event_type) && full_data |
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.
Can you avoid the NotificationType.names
lookup when full_data
is nil by swapping the order of this check?
@carbonin The idea is to use
Is there another place to put email message templates that work similar to notification templates? |
a32c1fd
to
4ffa807
Compare
Ah, that makes sense.
No that I know of, I was just curious. |
4ffa807
to
82c3d3f
Compare
I'm good with this change to notifications. I like the fact that the messages can be normalized for both notifications and email actions 👍 |
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'm good with this 👍
@@ -25,7 +25,16 @@ def validate_worker(w) | |||
if MiqWorker::STATUSES_CURRENT.include?(w.status) && usage_exceeds_threshold?(usage, memory_threshold) | |||
msg = "#{w.format_full_log_msg} process memory usage [#{usage}] exceeded limit [#{memory_threshold}], requesting worker to exit" | |||
_log.warn(msg) | |||
MiqEvent.raise_evm_event_queue(w.miq_server, "evm_worker_memory_exceeded", :event_details => msg, :type => w.class.name) | |||
helper = ApplicationController.helpers |
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.
@jrafanie Does/Will this cause an issue with respect to your work to run core without the UI code?
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.
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'm more than happy removing the helpers clause - I put that in to get the pretty megabytes thing displayed (that you suggested ;) )
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.
yeah, we shouldn't depend on ApplicationController here. I'm all for keeping raw bytes and changing the presentation to make it pretty.
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.
There is currently no place for the formatting.
I'll move over to ActiveSupport - that should be included in all gems (I assume)
app/models/notification.rb
Outdated
@@ -41,6 +44,12 @@ def seen_by_all_recipients? | |||
notification_recipients.unseen.empty? | |||
end | |||
|
|||
def self.notification_text(event_type, full_data) |
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 seems very event specific in it's wording, but the functionality seems general. Perhaps just rename event_type
to name
and full_data
to message_params
or something? Same goes for the emit_for_event method, but at least that method has event
in the name (I question whether an event specific thing belongs in Notification as opposed to EventStream)
This looks pretty good to me. I question coding event specific things into Notification class, but that's just organization problem. Overall, this is good stuff 👍 |
82c3d3f
to
4c5de3c
Compare
- Provide more complete information for worker out of memory errors - Provide notification messages for out of memory errors - Introduce ability to disable notification - Include notification.message in alert emails https://bugzilla.redhat.com/show_bug.cgi?id=1535177
4c5de3c
to
ebd613a
Compare
Checked commit kbrock@ebd613a with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
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'm 👍 now that it's 100% not dependent on ActionController.
Overview
Notifications provide information about events to users.
The workflows for larger customers rely more upon email than logging into the console.
manageiq can send out emails for these events using alerts. These emails do not have the rich information that the notifications provide.
In our particular case, when a workers is killed, only the server information is provided, not the worker itself.
Before
Alert Triggered
Alert 'aKB Worker killed', triggered
After
Alert Triggered
Alert 'aKB Worker killed', triggered
This PR adds a details section to the Alert emails.
notification#message
in alert emailsFollowup:
https://bugzilla.redhat.com/show_bug.cgi?id=1535177