Ver Fonte

HUE-2503 [jb] Better handling of expired YARN jobs

krish há 11 anos atrás
pai
commit
d211512d08

+ 11 - 1
apps/jobbrowser/src/jobbrowser/api.py

@@ -283,7 +283,10 @@ class YarnApi(JobBrowserApi):
     except ApplicationNotRunning, e:
       raise e
     except Exception, e:
-      raise PopupException('Job %s could not be found: %s' % (jobid, e), detail=e)
+      if 'NotFoundException' in str(e):
+        raise JobExpired(jobid)
+      else:
+        raise PopupException('Job %s could not be found: %s' % (jobid, e), detail=e)
 
     return job
 
@@ -304,3 +307,10 @@ class ApplicationNotRunning(Exception):
   def __init__(self, application_id, job):
     self.application_id = application_id
     self.job = job
+
+
+class JobExpired(Exception):
+
+  def __init__(self, job):
+    super(JobExpired, self).__init__('JobExpired: %s' %job)
+    self.job = job

+ 4 - 2
apps/jobbrowser/src/jobbrowser/views.py

@@ -41,7 +41,7 @@ from hadoop.api.jobtracker.ttypes import ThriftJobPriority, TaskTrackerNotFoundE
 from hadoop.yarn.clients import get_log_client
 
 from jobbrowser import conf
-from jobbrowser.api import get_api, ApplicationNotRunning
+from jobbrowser.api import get_api, ApplicationNotRunning, JobExpired
 from jobbrowser.models import Job, JobLinkage, Tracker, Cluster, can_view_job, can_modify_job
 
 import urllib2
@@ -59,8 +59,10 @@ def check_job_permission(view_func):
     except ApplicationNotRunning, e:
       # reverse() seems broken, using request.path but beware, it discards GET and POST info
       return job_not_assigned(request, jobid, request.path)
+    except JobExpired, e:
+      raise PopupException(_('Job %s has expired.') % jobid, detail=_('Cannot be found on the History Server.'))
     except Exception, e:
-       raise PopupException(_('Could not find job %s.') % jobid, detail=e)
+      raise PopupException(_('Could not find job %s.') % jobid, detail=e)
 
     if not conf.SHARE_JOBS.get() and not request.user.is_superuser \
         and job.user != request.user.username and not can_view_job(request.user.username, job):