Bug 1428219

Summary: Sync Errata should send emails only if Errata count is greater than 0
Product: Red Hat Satellite Reporter: Renu Chauhan <rchauhan>
Component: Errata ManagementAssignee: Kavita <kgaikwad>
Status: CLOSED ERRATA QA Contact: Walden Raines <walden>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, jcallaha, kgaikwad, nshaik, walden
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
URL: http://projects.theforeman.org/issues/18784
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 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:

Description Renu Chauhan 2017-03-02 03:36:29 UTC
Description of problem:Do not send "sync errata" email when there are no sync errata updates after repository synchronization.The mail for  syncing an errata should only be sent when actual errata updates are available or they are greater than zero. If a daily sync is applied then a mail is sent even if there are no errata updates avilable. 


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

How reproducible:
Always

Steps to Reproduce:
1.users = User.where(:mail => 'abc')  #<-- Create account add valid email and change email here
User.current = users.first
repo = Katello::Repository.find(383)   #<--- id of "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server"
last_updated = repo.repository_errata.order('updated_at ASC').last.try(:updated_at)
if last_updated
 errata = Katello::Erratum.where(:id => repo.repository_errata.where('katello_repository_errata.updated_at > ?', last_updated.to_datetime).pluck(:erratum_id))
 puts errata.size
 MailNotification[:sync_errata].deliver(:users => users, :repo => repo, :errata => errata)
end
~~

If there is a daily sync schedule then its annoying to receive daily mail with 0 errata 


Actual results:
A mail is received stating for errata update with 0 errata 

Expected results:
A mail for errata updates should only be triggered if the errata count is more than zero.

Additional info:

Comment 1 Satellite Program 2017-03-03 11:19:51 UTC
Upstream bug assigned to kgaikwad

Comment 3 Satellite Program 2017-03-17 18:19:16 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/18784 has been resolved.

Comment 5 Walden Raines 2017-08-02 18:35:34 UTC
Verified in 6.3.0 snap 9.

Comment 6 Satellite Program 2018-02-21 16:51:07 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/RHSA-2018:0336