Bug 1314897

Summary: retrace-server-worker --restart fails due to problem with writing retrace_log
Product: [Fedora] Fedora EPEL Reporter: Dave Wysochanski <dwysocha>
Component: retrace-serverAssignee: Dave Wysochanski <dwysocha>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: el6CC: jfilak, michal.toman, phelia
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: retrace-server-1.15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-03 07:25:52 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:
Attachments:
Description Flags
patch to fix this bug none

Description Dave Wysochanski 2016-03-04 19:24:23 UTC
Description of problem:
Now we get the following backtrace if we try a retrace-server-worker --restart.  Something changed in the management of the retrace_log file in the latest retrace-server-1.14-2.el6.noarch

$ retrace-server-worker --restart 984648283
Traceback (most recent call last):
  File "/usr/bin/retrace-server-worker", line 28, in <module>
    worker.begin_logging()
  File "/usr/lib/python2.6/site-packages/retrace/retrace_worker.py", line 17, in begin_logging
    self.task._get_file_path(RetraceTask.LOG_FILE))
  File "/usr/lib64/python2.6/logging/__init__.py", line 827, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib64/python2.6/logging/__init__.py", line 846, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: '/retrace/tasks/984648283/retrace_log'
$ ls -l /retrace/tasks/984648283/retrace_log
-rw-r--r--. 1 retrace retrace-group 2860 Dec 15 16:09 /retrace/tasks/984648283/retrace_log


This is due to a bug which slipped in during the refactor of the RetraceWorker.  The log file is removed along with other task state files in task.reset().  However we don't even get that far since we bomb when we try to 'begin_logging' and the retrace_log is readonly and we try to open in append mode.

We need something like this patch which re-orders begin_logging after the task.reset().

diff -Nurp /usr/bin/retrace-server-worker /usr/bin/retrace-server-worker.movelogging 
--- /usr/bin/retrace-server-worker      2016-02-23 02:58:06.000000000 -0500
+++ /usr/bin/retrace-server-worker.movelogging  2016-03-04 14:19:14.894349632 -0500
@@ -25,16 +25,17 @@ if __name__ == "__main__":
         exit(1)
 
     worker = task.create_worker()
-    worker.begin_logging()
 
     if task.has_status():
         if not cmdline.restart:
-            log_error("%s has already been executed for task %d" % (sys.argv[0], cmdline.task_id))
-            log_info("You can use --restart option if you really want to restart the task")
+            sys.stderr.write("%s has already been executed for task %d\n" % (sys.argv[0], cmdline.task_id))
+            sys.stdout.write("You can use --restart option if you really want to restart the task\n")
             worker._fail()
 
         task.reset()
 
+    worker.begin_logging()
+
     if not cmdline.foreground:
         try:
             pid = os.fork()


Version-Release number of selected component (if applicable):
retrace-server-1.14-2.el6.noarch


How reproducible:
Everytime on any task


Steps to Reproduce:
1. retrace-server-worker --restart <taskid>


Actual results:
backtrace 

Expected results:
--restart works as before

Additional info:

Comment 1 Dave Wysochanski 2016-03-04 20:22:33 UTC
Created attachment 1133238 [details]
patch to fix this bug

Comment 2 Dave Wysochanski 2016-03-05 00:23:31 UTC
Posted pull request on https://github.com/abrt/retrace-server

Comment 3 Mike McCune 2016-03-28 22:32:18 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions