Jelajahi Sumber

[jb] failsafe in cases where applicationType may not be available

Karissa McKelvey 11 tahun lalu
induk
melakukan
0cc14e00b9

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

@@ -264,7 +264,7 @@ class YarnApi(JobBrowserApi):
       elif job['state'] == 'KILLED':
         return KilledYarnJob(self.resource_manager_api, job)
 
-      if job['applicationType'] == 'SPARK':
+      if job.get('applicationType') == 'SPARK':
         job = SparkJob(job)
       else:
         # MR id, assume 'applicationType': 'MAPREDUCE'

+ 1 - 1
apps/jobbrowser/src/jobbrowser/models.py

@@ -131,7 +131,7 @@ class Job(JobLinkage):
     self._init_attributes()
     self.is_retired = hasattr(thriftJob, 'is_retired')
     self.is_mr2 = False
-    self.applicationType = thriftJob['applicationType']
+    self.applicationType = 'MR2'
 
   @property
   def counters(self):

+ 1 - 1
apps/jobbrowser/src/jobbrowser/views.py

@@ -127,7 +127,7 @@ def massage_job_for_json(job, request):
     'cleanupProgress': hasattr(job, 'cleanupProgress') and job.cleanupProgress or '',
     'desiredMaps': job.desiredMaps,
     'desiredReduces': job.desiredReduces,
-    'applicationType': job.applicationType,
+    'applicationType': hasattr(job, 'applicationType') and job.applicationType or None,
     'mapsPercentComplete': int(job.maps_percent_complete) if job.maps_percent_complete else '',
     'finishedMaps': job.finishedMaps,
     'finishedReduces': job.finishedReduces,