Bug #8795
closed
Email notifications can clutter the log
Added by Shimon Shtein about 10 years ago.
Updated over 9 years ago.
Description
Use case:
1. Set frequency of mail notification to "daily" in user settings (User -> MyAccount -> Mail preferences)
2. Unset the option "Mail enabled"
3. Run "rake reports:daily"
Expected: nothing happens
Actual: Exception in the logs
Can you provide a bit more info - what exception and logging are you seeing?
Note that some backtraces are printed at debug level, but wouldn't usually in production with info/warning logging only.
I'm talking about the exception that is thrown from our mailers, for example:
app/mailers/host_mailer.rb
In the first line of #summary you can see this line:
raise ::Foreman::Exception.new(N_("Must specify a user with email enabled")) unless (user=User.find(options[:user])) && user.mail_enabled?
It's an exception, so it will be risen as a warning (will be shown in production).
As far as I looked in the code of the rake task mechanism, there is no filtering of mailers based on #mail_enabled field. The only filtering is based on frequency, so if the frequency was once set, the code shown above would run, and if the #mail_enabled property is unset - it will raise an exception.
I can confirm, i see in my production logs:
Failed to send email notification puppet_error_state: ERF42-5670 [Foreman::Exception]: unable to find recipients
since this is repeating per client with errors, it might be occurring in the logs too often, but I'm not sure if we should remove it?
- Is duplicate of Bug #9795: Notification should never be sent if user has mail enabled added
- Status changed from New to Resolved
I believe #9795 has fixed this by putting a fast return inside the UserMailNotification.
Ohad Levy wrote:
I can confirm, i see in my production logs:
Failed to send email notification puppet_error_state: ERF42-5670 [Foreman::Exception]: unable to find recipients
Oh, and this is a slightly different condition (it's an alert, not a summary), but #9873 will fix that in the way it refactors alerting to groups.
- Is duplicate of Bug #9873: Failed report notifications for hosts owned by group only go to last user listed in group. added
Also available in: Atom
PDF