[master][PATCH] Put yum_lock logging to a separate file and just attach it

Vratislav Podzimek vpodzime at redhat.com
Fri Nov 15 10:11:59 UTC 2013


In some cases, yum_lock logs may grow to megabytes (especially with slow
Internet connection) which makes anaconda-tb file generation take at least tens
of seconds (i. e. it takes tens of seconds for the exception dialog to appear)
and the resulting file is so big that it is considered a binary attachement by
libreport/bugzilla.

This change makes exception dialog appear in a few seconds with the anaconda-tb
size reduced to hundreds of kilobytes.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/anaconda_log.py         |  7 +++++++
 pyanaconda/exception.py            | 10 ++++++++++
 pyanaconda/packaging/yumpayload.py |  7 ++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py
index c71181f..e52d826 100644
--- a/pyanaconda/anaconda_log.py
+++ b/pyanaconda/anaconda_log.py
@@ -43,6 +43,7 @@ PROGRAM_LOG_FILE = "/tmp/program.log"
 PROGRAM_LOG_TTY = "/dev/tty5"
 STORAGE_LOG_FILE = "/tmp/storage.log"
 PACKAGING_LOG_FILE = "/tmp/packaging.log"
+YUM_LOCK_LOG_FILE = "/tmp/yum_lock.log"
 SENSITIVE_INFO_LOG_FILE = "/tmp/sensitive-info.log"
 ANACONDA_SYSLOG_FACILITY = SysLogHandler.LOG_LOCAL1
 
@@ -128,6 +129,12 @@ class AnacondaLog:
                             minLevel=logging.DEBUG)
         self.forwardToSyslog(packaging_logger)
 
+        # Create the yum_lock logger.
+        yum_lock_logger = logging.getLogger("yum_lock")
+        yum_lock_logger.setLevel(logging.DEBUG)
+        self.addFileHandler(YUM_LOCK_LOG_FILE, yum_lock_logger,
+                            minLevel=logging.DEBUG)
+
         # Create the yum logger and link it to packaging
         yum_logger = logging.getLogger("yum")
         yum_logger.setLevel(logging.DEBUG)
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index e61cce0..cd46064 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -38,6 +38,7 @@ from pyanaconda.constants import ROOT_PATH, THREAD_EXCEPTION_HANDLING_TEST
 from pyanaconda.threads import threadMgr
 from pyanaconda.i18n import _
 from pyanaconda import flags
+from pyanaconda import product
 
 from gi.repository import GLib
 
@@ -236,6 +237,9 @@ def initExceptionHandling(anaconda):
         # anaconda-tb file
         conf.register_callback("journalctl", journalctl_callback, attchmnt_only=False)
 
+    if not product.isFinal:
+        conf.register_callback("yum_lock.log", yum_lock_log_callback, attchmnt_only=True)
+
     handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
                                        ReverseExceptionDump, anaconda.intf.tty_num)
     handler.install(anaconda)
@@ -266,6 +270,12 @@ def journalctl_callback():
 
     return ret
 
+def yum_lock_log_callback():
+    """Callback to get our yum_lock log."""
+
+    with open("/tmp/yum_lock.log", "r") as fobj:
+        return fobj.read()
+
 def test_exception_handling():
     """
     Function that can be used for testing exception handling in anaconda. It
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 2f2813a..7323b8a 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -45,6 +45,7 @@ from functools import wraps
 
 import logging
 log = logging.getLogger("packaging")
+yum_lock_log = logging.getLogger("yum_lock")
 
 try:
     import rpm
@@ -103,16 +104,16 @@ class YumLock(object):
         frame = inspect.stack()[2]
         threadName = threading.currentThread().name
 
-        log.info("about to acquire _yum_lock for %s at %s:%s (%s)", threadName, frame[1], frame[2], frame[3])
+        yum_lock_log.info("about to acquire _yum_lock for %s at %s:%s (%s)", threadName, frame[1], frame[2], frame[3])
         _private_yum_lock.acquire()
-        log.info("have _yum_lock for %s", threadName)
+        yum_lock_log.info("have _yum_lock for %s", threadName)
         return _private_yum_lock
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         _private_yum_lock.release()
 
         if not isFinal:
-            log.info("gave up _yum_lock for %s", threading.currentThread().name)
+            yum_lock_log.info("gave up _yum_lock for %s", threading.currentThread().name)
 
 def invalidates_br_cache(cond_fn=None):
     """
-- 
1.8.3.1



More information about the anaconda-patches mailing list