Эх сурвалжийг харах

HUE-2664 [jobbrowser] Fix fetching logs from job history server

While the job is active we need to hack up the url we're receiving
from YARN in order to point at the right location. However this
is wrong to do after the job has been migrated to the history server.
So this patch just skips modifying the url if it happens to be
pointed at the job history server.
Erick Tryzelaar 10 жил өмнө
parent
commit
b7b7ba5

+ 11 - 4
apps/jobbrowser/src/jobbrowser/yarn_models.py

@@ -28,6 +28,7 @@ from django.utils.translation import ugettext as _
 from desktop.lib.rest.resource import Resource
 from desktop.lib.view_util import format_duration_in_millis
 
+from hadoop.conf import YARN_CLUSTERS
 from hadoop.yarn.clients import get_log_client
 
 from jobbrowser.models import format_unixtime_ms
@@ -351,10 +352,16 @@ class Attempt:
     attempt = self.task.job.job_attempts['jobAttempt'][-1]
     log_link = attempt['logsLink']
     # Get MR task logs
-    if self.assignedContainerId:
-      log_link = log_link.replace(attempt['containerId'], self.assignedContainerId)
-    if hasattr(self, 'nodeHttpAddress'):
-      log_link = log_link.replace(attempt['nodeHttpAddress'].split(':')[0], self.nodeHttpAddress.split(':')[0])
+
+    # Don't hack up the urls if they've been migrated to the job history server.
+    for cluster in YARN_CLUSTERS.get().itervalues():
+      if log_link.startswith(cluster.HISTORY_SERVER_API_URL.get()):
+        break
+    else:
+      if self.assignedContainerId:
+        log_link = log_link.replace(attempt['containerId'], self.assignedContainerId)
+      if hasattr(self, 'nodeHttpAddress'):
+        log_link = log_link.replace(attempt['nodeHttpAddress'].split(':')[0], self.nodeHttpAddress.split(':')[0])
 
     for name in ('stdout', 'stderr', 'syslog'):
       link = '/%s/' % name