Bug 2245056

Summary: Long running task watching can trigger itself under certain scenarios
Product: Red Hat Satellite Reporter: Adam Ruzicka <aruzicka>
Component: Tasks PluginAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Pavel Novotny <pnovotny>
Severity: high Docs Contact:
Priority: high    
Version: 6.13.0CC: aruzicka, pcreech, pnovotny, rlavi
Target Milestone: 6.14.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman-tasks-8.3.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-08 14:20:21 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 Adam Ruzicka 2023-10-19 13:29:37 UTC
Description of problem:
Long running task watching can trigger itself under certain scenarios


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


How reproducible:
Always


Steps to Reproduce:
1. Have a long running task (paused or running for more than 2 days)
2. Wait a day


Actual results:
Long running task watching kicks in and tries to email all admin users (and users who opt in for it). It also tries to email internal admin users who don't have email set. This will fail and the task watching task will go into paused state, thus triggering the notification attempt next time the check runs. The same issue can occur if you create an admin user without email.


Expected results:
Internal admin users and users without email set are ignored (delivery to those users is not attempted at all). If the delivery does fail for some reason, the task should go into stopped-error (or warning) so that it gets out of the way and doesn't trigger itself the next time it runs.


Additional info:
Task cleanup seems to be the most reliable way to get out of this circle of broken self-reporting.

Comment 1 Adam Ruzicka 2023-10-19 13:32:07 UTC
Version-Release number of selected component (if applicable) should be 6.14, sorry about that.

Comment 2 Bryan Kearney 2023-10-20 12:02:54 UTC
Upstream bug assigned to aruzicka

Comment 3 Bryan Kearney 2023-10-20 12:02:56 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36848 has been resolved.

Comment 4 Adam Ruzicka 2023-10-20 12:51:10 UTC
Releases containing fixes for this are now available in upstream.
6.15 compatible version is rubygem-foreman-tasks-8.3.1
6.14 compatible version is rubygem-foreman-tasks-8.1.3

Comment 5 Adam Ruzicka 2023-10-23 08:27:48 UTC
There was another issue found and fixed. Releases containing fixes for this are now available in upstream.
6.15 compatible version is rubygem-foreman-tasks-8.3.2
6.14 compatible version is rubygem-foreman-tasks-8.1.4

Comment 7 Pavel Novotny 2023-10-25 18:10:34 UTC
Verified in Satellite 6.14 snap 21:
rubygem-foreman-tasks-8.1.4-1.el8sat.noarch
satellite-6.14.0-3.el8sat.noarch

Verified according to reproducer from comment 0.

Tested with 2 groups of users:

Group 1 - users that should receive email notifications:

- admin user with Email Address set & Mail Enabled checked
- user with Org. admin role with Email Address set & Mail Enabled checked
- user without Org. admin role with Email Address set & Mail Enabled checked & subscribed to 'Long running tasks'

This group received email notification about any long running task.
The task 'Check for long running tasks' finished with success.


Group 2 - user matrix that should not receive email notifications:

_____________________	| admin user	| Org. admin role user	| regular user	|
blank email *1)		|	x	|	x		|	x	|
email disabled *2)	|	x	|	x		|	x	|
user disabled *3)	|	x	|	x		|	x	|

*1) Mail Enabled checked
*2) Email Address set
*3) Email Address set & Mail Enabled checked

With this group of users, neither of them received email about long running tasks.
The task 'Check for long running tasks' finished also with success and didn't remain stuck in paused state.

Comment 9 errata-xmlrpc 2023-11-08 14:20:21 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 (Important: Satellite 6.14 security and bug fix update), 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-2023:6818