Преглед на файлове

[jobbrowser] Additional log info for debugging

krish преди 10 години
родител
ревизия
c1f874f
променени са 2 файла, в които са добавени 19 реда и са изтрити 4 реда
  1. 12 3
      apps/jobbrowser/src/jobbrowser/views.py
  2. 7 1
      apps/jobbrowser/src/jobbrowser/yarn_models.py

+ 12 - 3
apps/jobbrowser/src/jobbrowser/views.py

@@ -48,6 +48,9 @@ from jobbrowser.models import Job, JobLinkage, Tracker, Cluster, can_view_job, c
 import urllib2
 
 
+LOGGER = logging.getLogger(__name__)
+
+
 def check_job_permission(view_func):
   """
   Ensure that the user has access to the job.
@@ -274,14 +277,20 @@ def job_attempt_logs_json(request, job, attempt_index=0, name='syslog', offset=0
     params['start'] = offset
 
   root = Resource(get_log_client(log_link), urlparse.urlsplit(log_link)[2], urlencode=False)
-
+  debug_info = ''
   try:
     response = root.get(link, params=params)
     log = html.fromstring(response).xpath('/html/body/table/tbody/tr/td[2]')[0].text_content()
   except Exception, e:
-    log = _('Failed to retrieve log: %s') % e
+    log = _('Failed to retrieve log: %s' % e)
+    try:
+      debug_info = _('\nLog Link: %s' % log_link)
+      debug_info += _('\nHTML Response: %s' % response)
+      LOGGER.error(debug_info)
+    except:
+      pass
 
-  response = {'log': log}
+  response = {'log': log, 'debug': debug_info}
 
   return JsonResponse(response)
 

+ 7 - 1
apps/jobbrowser/src/jobbrowser/yarn_models.py

@@ -339,7 +339,13 @@ class Attempt:
         response = root.get(link, params=params)
         log = html.fromstring(response).xpath('/html/body/table/tbody/tr/td[2]')[0].text_content()
       except Exception, e:
-        log = _('Failed to retrieve log: %s') % e
+        log = _('Failed to retrieve log: %s' % e)
+        try:
+          debug_info = _('\nLog Link: %s' % log_link)
+          debug_info += _('\nHTML Response: %s' % response)
+          LOGGER.error(debug_info)
+        except:
+          pass
 
       logs.append(log)