Bug 1314897 - retrace-server-worker --restart fails due to problem with writing retrace_log
Summary: retrace-server-worker --restart fails due to problem with writing retrace_log
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: retrace-server
Version: el6
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Dave Wysochanski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-04 19:24 UTC by Dave Wysochanski
Modified: 2016-06-03 07:25 UTC (History)
3 users (show)

Fixed In Version: retrace-server-1.15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-03 07:25:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
patch to fix this bug (2.97 KB, patch)
2016-03-04 20:22 UTC, Dave Wysochanski
no flags Details | Diff

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


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