Project

General

Profile

Actions

Bug #26310

closed

foreman-rake tasks:cleanup combining specific TASK_SEARCH and STATES can delete unwanted tasks as well

Added by Adam Ruzicka about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1687784

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

?

Actions #1

Updated by The Foreman Bot about 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Adam Ruzicka
  • Pull request https://github.com/theforeman/foreman-tasks/pull/394 added
Actions #2

Updated by Anonymous about 5 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF