Bug 1314207 - Task export should include successful tasks as well as the pending or errored one
Task export should include successful tasks as well as the pending or errored...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Tasks Plugin (Show other bugs)
6.1.6
x86_64 Linux
unspecified Severity high (vote)
: 6.2.3
: --
Assigned To: David Davis
Peter Ondrejka
http://projects.theforeman.org/issues...
: PrioBumpGSS, PrioBumpPM, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-03 03:51 EST by Marcel Gazdík
Modified: 2016-10-26 08:25 EDT (History)
10 users (show)

See Also:
Fixed In Version: rubygem-foreman-tasks-0.7.14.8-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-10-26 08:25:35 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 14487 None None None 2016-04-26 12:58 EDT

  None (edit)
Description Marcel Gazdík 2016-03-03 03:51:00 EST
Description of problem:
  Current behavior of foreman-debug, specifically task export might not be  sufficient when we are looking for performance issues. I. e. if I can see error message: "[E] Required lock is already taken by other running tasks." and I need to check the actual task which had the locks and this task finished successfully, it will not be included later, when the foreman-debug performs task export script.

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

How reproducible:
Just run foreman-debug and look for successful tasks in the task export


Actual results:
Successful tasks are missing in the task export

Expected results:
Successful task will be included in the task export

Additional info:
Current implementation:

#foreman-tasks export
if hash foreman-rake  2>/dev/null; then
  echo "Exporting tasks, this may take a few minutes."
  tasks_filename=`foreman-rake foreman_tasks:export_tasks 2> /tmp/tasks_export.log | tail -n 1 | awk '{print $2}'`
  copy_files $tasks_filename
  add_files /tmp/tasks_export.log
fi


Proposed modification:
#foreman-tasks export
if hash foreman-rake  2>/dev/null; then
  echo "Exporting tasks, this may take a few minutes."
  tasks_filename=`foreman-rake foreman_tasks:export_tasks tasks=all days=14 2> /tmp/tasks_export.log | tail -n 1 | awk '{print $2}'`
  copy_files $tasks_filename
  add_files /tmp/tasks_export.log
fi


Because there might be a lot of tasks, I believe it will be good to limit the age of tasks included in the task export. Therefore I'm proposing 14 days as I think it should be more than sufficient.
Comment 2 Bryan Kearney 2016-04-05 13:47:50 EDT
Created redmine issue http://projects.theforeman.org/issues/14487 from this bug
Comment 3 Bryan Kearney 2016-04-06 04:06:43 EDT
Upstream bug component is Content Management
Comment 4 Bryan Kearney 2016-04-18 10:06:59 EDT
Upstream bug component is Tasks Plugin
Comment 5 Ivan Necas 2016-04-25 09:53:50 EDT
I suggest the search-based param to the export, similar as we have in cleanup task

https://github.com/theforeman/foreman-tasks/blob/master/lib/foreman_tasks/tasks/cleanup.rake#L6

It would be customizable by an environment variable, with some sane default, that we can discuss here.
Comment 8 David Davis 2016-05-17 09:03:56 EDT
The export task can already export successful tasks but it doesn't do so by default. See:

https://git.io/vrCR2
https://git.io/vrCRV
Comment 9 David Davis 2016-05-17 09:04:47 EDT
I do like the idea of removing 'tasks' and adding a 'filter' option but I worry about backwards compatibility (ie is anyone using 'tasks'?).
Comment 10 Ivan Necas 2016-05-17 10:05:56 EDT
We can keep the ENV['tasks'] there, maybe with deprecation with suggestion to use the filter instead
Comment 11 Bryan Kearney 2016-05-17 12:31:29 EDT
Upstream bug assigned to inecas@redhat.com
Comment 12 Bryan Kearney 2016-05-18 04:18:26 EDT
Upstream bug assigned to daviddavis@redhat.com
Comment 14 Ivan Necas 2016-06-02 06:26:48 EDT
The PR that fixes the issue is available https://github.com/theforeman/foreman-tasks/pull/186
Comment 15 David Davis 2016-06-02 15:39:40 EDT
Now, to do a foreman-debug that would include all tasks (and not just errorred ones), you'd do:

export TASK_SEARCH=''
foreman-debug
Comment 16 Ivan Necas 2016-06-03 04:41:13 EDT
I don't think we should include all the successful tasks by default there. @Marcel: Would the solution, where one would specify the TASK_SEARCH to get something more
work for you:

 foreman-rake foreman_tasks:export_tasks TASK_SEARCH=''

The TASK_SEARCH accepts the search field in the same format it does in the tasks page in the UI.

It should be also possible to do it via this approach

  export TASK_SEARCH=''
  foreman-debug

For this part, we would need to pull this change in https://github.com/theforeman/foreman/pull/3534 to propagate the env variables to the foreman-rake.
Comment 17 Mike McCune 2016-06-03 14:42:54 EDT
+1 to the suggestion above. We should keep the behavior the same for the default but offer a route to exporting all the tasks or different selections based on an variable.

By default, exporting all tasks can be quite large and greatly increase the size of foreman-debug's output.
Comment 18 Marcel Gazdík 2016-06-06 14:47:05 EDT
@Ivan: Your suggestion has a point and it might be beneficial for us. But I do not know if the effort put into modifying of the code would be necessary when we can use the foreman-rake as it is. I was pointing on this because a lot of customer is giving us sosreports / foreman-debugs which includes the task export with all failed/pending tasks. However, it happened to me many times, that I needed to see also the successful tasks since they were blockers for the failed one, ore for deeper debugging and I have to ask the CU specifically for it again and again which is just stalling us in the work which could be done automatically. 
  We also do not need to include all the tasks since the time the satellite was installed, just few days in the past, say 7 or 14 as I do not expect that there will be reason for going more into the history and if so, we can again use the foreman-rake foreman_tasks:export_tasks command with its options.
Comment 19 Ivan Necas 2016-06-07 18:12:40 EDT
The thing is we already put the effort into modifying the code. We can consider changing the default if you feel it would help the customer experience.

What about exporting all failed in the past 60 days and all in the past 7 days? Is that a reasonable default?
Comment 20 Marcel Gazdík 2016-06-08 11:28:49 EDT
@Ivan: I believe we can go this way, make it 60 for the failed one and 7 for the rest as you said.
Comment 21 David Davis 2016-06-08 15:12:03 EDT
Ok, going to update the export task.
Comment 22 Bryan Kearney 2016-08-10 04:12:37 EDT
Moving to POST since upstream bug http://projects.theforeman.org/issues/14487 has been closed
Comment 23 Peter Ondrejka 2016-10-11 06:45:03 EDT
Verified in satellite-6.2.3-1.0, successful stopped tasks are indeed included in task export. By inserting an "old" task into the the db confirmed that successful tasks older than 7 days are not included in task export.
Comment 25 errata-xmlrpc 2016-10-26 08:25:35 EDT
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-2016:2108

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