Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1687784 - foreman-rake tasks:cleanup combining specific TASK_SEARCH and STATES can delete unwanted tasks as well
Summary: foreman-rake tasks:cleanup combining specific TASK_SEARCH and STATES can dele...
Keywords:
Status: POST
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Tasks Plugin
Version: 6.4.2
Hardware: x86_64
OS: Linux
high
high vote
Target Milestone: Unspecified
Assignee: Adam Ruzicka
QA Contact: Jan Hutař
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-12 11:35 UTC by Pavel Moravec
Modified: 2019-03-20 16:02 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 26310 None None None 2019-03-12 11:40:30 UTC

Description Pavel Moravec 2019-03-12 11:35:38 UTC
Description of problem:
TASK_SEARCH and STATES parameters in tasks cleanup should work in conjunction. However, when combining some values of TASK_SEARCH and STATES, also unexpected tasks are removed.

Example:

TASK_SEARCH='result = pending or result = error' STATES='paused,planning'

will remove pending/running tasks (i.e. monitor event and LOCE task).


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


How reproducible:
100%


Steps to Reproduce:
1. Have running Satellite with all "usual" tasks planned or running (monitor event, LOCE, Pulp disk space etc.)
2. Check tasks cumulative stats:

sudo su - postgres -c "psql -d foreman -c 'select label,count(label),state,result from foreman_tasks_tasks where state <> '\''stopped'\'' group by label,state,result ORDER BY label;'"

3. Remove tasks that with pending or error result AND in paused or planning state:

foreman-rake foreman_tasks:cleanup TASK_SEARCH='result = pending or result = error' STATES='paused,planning' VERBOSE=true

4. Check tasks cumulative stats again:

sudo su - postgres -c "psql -d foreman -c 'select label,count(label),state,result from foreman_tasks_tasks where state <> '\''stopped'\'' group by label,state,result ORDER BY label;'"


Actual results:
2. shows expected:
                    label                    | count |   state   | result  
---------------------------------------------+-------+-----------+---------
 Actions::Candlepin::ListenOnCandlepinEvents |     1 | running   | pending
 Actions::Katello::EventQueue::Monitor       |     1 | running   | pending
 CreatePulpDiskSpaceNotifications            |     2 | scheduled | pending
 CreateRssNotifications                      |     2 | scheduled | pending
 SendExpireSoonNotifications                 |     2 | scheduled | pending
                                             |     0 | pending   | success
(6 rows)

BUT 4. shows nothing:
 label | count |  state  | result  
-------+-------+---------+---------
       |     0 | pending | success
(1 row)


Expected results:
both 2. and 4 to show same "default" tasks


Additional info:
Per aruzicka++, the problem seems in missing parenthesis in the underlying postgres query (if I got it right), where the above query is translated to:

result=pending OR (result=error AND state in (paused,planning))

instead of proper:

(result=pending OR result=error) AND (state in (paused,planning))


BUT this does not explain deletion of tasks

CreatePulpDiskSpaceNotifications            |     2 | scheduled | pending

?

Comment 3 Adam Ruzicka 2019-03-12 11:40:29 UTC
Created redmine issue http://projects.theforeman.org/issues/26310 from this bug

Comment 4 Bryan Kearney 2019-03-12 12:02:03 UTC
Upstream bug assigned to aruzicka@redhat.com

Comment 5 Bryan Kearney 2019-03-12 12:02:05 UTC
Upstream bug assigned to aruzicka@redhat.com

Comment 6 Bryan Kearney 2019-03-20 16:02:20 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26310 has been resolved.


Note You need to log in before you can comment on or make changes to this bug.