Skip to content

Commit 657ec18

Browse files
author
Marcelo Vanzin
committed
Fix yarn history URL, app links.
1 parent c3e0a82 commit 657ec18

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
153153
val conf = this.conf.clone()
154154
val appSecManager = new SecurityManager(conf)
155155
SparkUI.createHistoryUI(conf, replayBus, appSecManager, appId,
156-
s"${HistoryServer.UI_PATH_PREFIX}/$appId")
156+
HistoryServer.getAttemptURI(appId, attempt.attemptId))
157157
// Do not call ui.bind() to avoid creating a new server for each application
158158
}
159159

core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,12 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
154154
<a href={makePageLink(nextPage, showIncomplete)}> {nextPage} </a>)
155155
}
156156

157-
private def getAttemptURI(appId: String, attemptInfo: ApplicationAttemptInfo): String = {
158-
val attemptSuffix = if (!attemptInfo.attemptId.isEmpty) s"/${attemptInfo.attemptId}" else ""
159-
s"${HistoryServer.UI_PATH_PREFIX}/${appId}${attemptSuffix}"
160-
}
161-
162157
private def attemptRow(
163158
renderAttemptIdColumn: Boolean,
164159
info: ApplicationHistoryInfo,
165160
attempt: ApplicationAttemptInfo,
166161
isFirst: Boolean): Seq[Node] = {
167-
val uiAddress = getAttemptURI(info.id, attempt)
162+
val uiAddress = HistoryServer.getAttemptURI(info.id, attempt.attemptId)
168163
val startTime = UIUtils.formatDate(attempt.startTime)
169164
val endTime = if (attempt.endTime > 0) UIUtils.formatDate(attempt.endTime) else "-"
170165
val duration =
@@ -191,7 +186,8 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
191186
{
192187
if (renderAttemptIdColumn) {
193188
if (info.attempts.size > 1 && !attempt.attemptId.isEmpty) {
194-
<td><a href={getAttemptURI(info.id, attempt)}>{attempt.attemptId}</a></td>
189+
<td><a href={HistoryServer.getAttemptURI(info.id, attempt.attemptId)}>
190+
{attempt.attemptId}</a></td>
195191
} else {
196192
<td>&nbsp;</td>
197193
}

core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,9 @@ object HistoryServer extends Logging {
224224
}
225225
}
226226

227+
private[history] def getAttemptURI(appId: String, attemptId: String): String = {
228+
val attemptSuffix = if (!attemptId.isEmpty) s"/${attemptId}" else ""
229+
s"${HistoryServer.UI_PATH_PREFIX}/${appId}${attemptSuffix}"
230+
}
231+
227232
}

yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ private[spark] class ApplicationMaster(
225225
val sc = sparkContextRef.get()
226226

227227
val appId = client.getAttemptId().getApplicationId().toString()
228+
val attemptId = client.getAttemptId().getAttemptId().toString()
228229
val historyAddress =
229230
sparkConf.getOption("spark.yarn.historyServer.address")
230-
.map { address => s"${address}${HistoryServer.UI_PATH_PREFIX}/${appId}" }
231+
.map { address => s"${address}${HistoryServer.UI_PATH_PREFIX}/${appId}/${attemptId}" }
231232
.getOrElse("")
232233

233234
allocator = client.register(yarnConf,

0 commit comments

Comments
 (0)