Bug 1369817

Summary: Email notification fails for Satellite Promotion and Satellite Sync Summary
Product: Red Hat Satellite Reporter: anerurka
Component: EmailAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Bruno Rocha <rochacbruno>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2.0CC: bbuckingham, bkearney, brubisch, gpayelka, jcallaha, mburgerh, mklein, omaciel, peter.vreman, pmoravec, rdixon, rochacbruno, stbenjam, szadok, xdmoon, zhunting
Target Milestone: UnspecifiedKeywords: PrioBumpGSS, Regression, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.105-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1417069 (view as bug list) Environment:
Last Closed: 2017-03-06 08:27:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1122832, 1385841, 1417069    
Attachments:
Description Flags
foreman-debug
none
foreman-debug-6.2.8-3.0
none
Email received none

Description anerurka 2016-08-24 13:23:55 UTC
Description of problem:

Email notification fails for Satellite Promotion  and Satellite Sync Summary 


Version-Release number of selected component (if applicable):

Satellite 6.2

How reproducible:

Always


Steps to Reproduce:

1.Configure Satellite 6.2 with smtp settings.
2.Register one or two clients.(Install katello-agent)
3. Sync any Repository
4. Publish or Promote Content View


Actual results:

No email notification received to the user email id


Expected results

Email Notification should be received


Additional info:
It works fine on Satellite 6.1.9, please check the attached image.

Comment 3 Bryan Kearney 2016-08-29 18:23:30 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16303 has been resolved.

Comment 5 Og Maciel 2016-10-19 19:44:57 UTC
This fails for me on Satellite 6.3.0 SNAP 5.0 with the following error:

==> /var/log/foreman/production.log <==
2016-10-19 15:36:00  [app] [E] Unable to send errata e-mail notification: undefined method `deliver_now' for #<MailNotification:0x0000000d83edb8>

The fix for this issue seems to be:

diff --git a/app/lib/actions/katello/content_view/errata_mail.rb b/app/lib/actions/katello/content_view/errata_mail.rb
index beb41e7..9f66672 100644
--- a/app/lib/actions/katello/content_view/errata_mail.rb
+++ b/app/lib/actions/katello/content_view/errata_mail.rb
@@ -11,10 +11,10 @@ def run
 
           content_view = ::Katello::ContentView.find(input[:content_view])
           environment = ::Katello::KTEnvironment.find(input[:environment])
-          users = ::User.select { |user| user.receives?(:katello_promote_errata) && user.can?(:view_content_views, content_view) }
+          users = ::User.select { |user| user.receives?(:promote_errata) && user.can?(:view_content_views, content_view) }
 
           begin
-            MailNotification[:katello_promote_errata].deliver_now(:users => users, :content_view => content_view, :environment => environment) unless users.blank?
+            MailNotification[:promote_errata].deliver_now(:users => users, :content_view => content_view, :environment => environment) unless users.blank?
           rescue => e
             message = _('Unable to send errata e-mail notification: %{error}' % {:error => e})
             Rails.logger.error(message)
diff --git a/app/lib/actions/katello/repository/errata_mail.rb b/app/lib/actions/katello/repository/errata_mail.rb
index 5bebc32..8550ad4 100644
--- a/app/lib/actions/katello/repository/errata_mail.rb
+++ b/app/lib/actions/katello/repository/errata_mail.rb
@@ -13,11 +13,11 @@ def run
           ::User.current = ::User.anonymous_admin
 
           repo = ::Katello::Repository.find(input[:repo])
-          users = ::User.select { |user| user.receives?(:katello_sync_errata) && user.can?(:view_products, repo.product) }.compact
+          users = ::User.select { |user| user.receives?(:sync_errata) && user.can?(:view_products, repo.product) }.compact
           errata = ::Katello::Erratum.where(:id => repo.repository_errata.where('katello_repository_errata.updated_at > ?', input[:last_updated].to_datetime).pluck(:erratum_id))
 
           begin
-            MailNotification[:katello_sync_errata].deliver_now(:users => users, :repo => repo, :errata => errata) unless users.blank?
+            MailNotification[:sync_errata].deliver_now(:users => users, :repo => repo, :errata => errata) unless users.blank?
           rescue => e
             message = _('Unable to send errata e-mail notification: %{error}' % {:error => e})
             Rails.logger.error(message)

and I can verify that these changes are in my system:


# rpm -ql tfm-rubygem-katello-3.2.0-0.2.rc2.el7.noarch |grep mail.rb
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/content_view/errata_mail.rb
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/repository/errata_mail.rb

# sed '14!d' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/content_view/errata_mail.rb
          users = ::User.select { |user| user.receives?(:promote_errata) && user.can?(:view_content_views, content_view) }

# sed '17!d' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/content_view/errata_mail.rb
            MailNotification[:promote_errata].deliver_now(:users => users, :content_view => content_view, :environment => environment) unless users.blank?

# sed '16!d' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/repository/errata_mail.rb
          users = ::User.select { |user| user.receives?(:sync_errata) && user.can?(:view_products, repo.product) }.compact

# sed '20!d' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0.rc2/app/lib/actions/katello/repository/errata_mail.rb
            MailNotification[:sync_errata].deliver_now(:users => users, :repo => repo, :errata => errata) unless users.blank?

Comment 6 Og Maciel 2016-10-19 19:59:47 UTC
Created attachment 1212252 [details]
foreman-debug

# foreman-debug
Processing... (takes a while)cp: '/etc/foreman-installer/scenarios.d/foreman.migrations/.applied' and '/tmp/foreman-debug-Ta6Ob/etc/foreman-installer/scenarios.d/foreman.migrations/.applied' are the same file
Exporting tasks, this may take a few minutes.
Copying entire file: /tmp/task-export-1476907080.tar.gz


 HOSTNAME: ibm-x3250m4-03.lab.eng.rdu2.redhat.com
       OS: redhat
  RELEASE: Red Hat Enterprise Linux Server release 7.2 (Maipo)
  FOREMAN: 1.13.0
     RUBY: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
   PUPPET: 3.8.6
  DENIALS: 20


A debug file has been created: /tmp/foreman-debug-Ta6Ob.tar.xz (5996612 bytes)

To upload a tarball to our secure site, please use the -u option.

Comment 7 Og Maciel 2016-10-19 20:00:29 UTC
Talked to jsherrill and he agreed that we should FailQE this issue. Attached logs as requested on irc

Comment 12 Peter Vreman 2017-01-04 11:34:03 UTC
I have applied the patch from https://github.com/Katello/katello/pull/6278 on Sat6.2.6 and that works.

Comment 13 Shlomi Zadok 2017-01-04 12:57:17 UTC
@peter++

Moving to POST :)

Comment 15 Og Maciel 2017-02-21 20:08:45 UTC
Still seeing 2017-02-21 15:07:48 [app] [E] Unable to send errata e-mail notification: undefined method `deliver_now' for #<MailNotification:0x0000000dd66480>

Comment 16 Bruno Rocha 2017-02-21 20:42:32 UTC
Created attachment 1256244 [details]
foreman-debug-6.2.8-3.0

Comment 17 Bruno Rocha 2017-02-21 20:51:50 UTC
Failed QE in:

6.2.8 3.0

foreman-installer-katello-3.0.0.77-1.el7sat.noarch.rpm
katello-installer-base-3.0.0.77-1.el7sat.noarch.rpm
ostree-2017.1-2.atomic.el7.x86_64.rpm
tfm-rubygem-katello-3.0.0.103-1.el7sat.noarch.rpm
tfm-rubygem-katello_ostree-3.0.0.103-1.el7sat.noarch.rpm
tfm-rubygem-unicode-display_width-1.0.5-2.el7sat.noarch.rpm


Steps:

1) Created new user and subscribed to "Promote Errata" and "Sync Errata" mailing.
2) Created product + repository 
3) Sync repository in Content Sync Status

Repository Sync ok and 4 erratas added.

Expected:

Mail notification

Result:

No mail notification and error showed on foreman/production.log.

2017-02-21 15:04:24 [app] [E] Unable to send errata e-mail notification: undefined method `deliver_now' for #<MailNotification:0x0000000b26a498>

foreman-debug attached.

Comment 18 Brad Buckingham 2017-02-21 21:07:08 UTC
The failure looks to be due to rails 4.2 (upstream) vs 4.1 (downstream).  In the upstream, the mail notifications have been updated to support the 'deliver_now' method; however, that doesn't exist in 4.1.

I'll submit an MR shortly with the change.

Comment 21 Bruno Rocha 2017-03-02 18:21:54 UTC
Created attachment 1259246 [details]
Email received

Comment 22 Bruno Rocha 2017-03-02 18:23:21 UTC
Verified in:

 satellite-6.2.8-4.0.el7sat.noarch


Result:

  Sync Summary email received! (attached screenshot)

Comment 24 errata-xmlrpc 2017-03-06 08:27:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:0447