Skip to content

Commit

Permalink
Bug 1347655 - Don't use "inspect task" link to get tc id of decision …
Browse files Browse the repository at this point in the history
…task (#2257)
  • Loading branch information
wlach committed Mar 16, 2017
1 parent 2b0ef8a commit 9ff7e98
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
8 changes: 4 additions & 4 deletions ui/js/controllers/tcjobactions.js
Expand Up @@ -50,14 +50,14 @@ treeherder.controller('TCJobActionsCtrl', [
}
});

let decisionTaskId = ThResultSetStore.getGeckoDecisionTaskGUID(repoName, resultsetId);
if (decisionTaskId) {
let decisionTask = ThResultSetStore.getGeckoDecisionJob(repoName, resultsetId);
if (decisionTask) {
let originalTaskId = job.taskcluster_metadata.task_id;
$http.get('https://queue.taskcluster.net/v1/task/' + originalTaskId).then(
function(response) {
originalTask = response.data;
ThJobDetailModel.getJobDetails({
job_guid: decisionTaskId,
job_id: decisionTask.id,
title: 'artifact uploaded',
value: 'actions.json'}).then(function(details) {
if (!details.length) {
Expand Down Expand Up @@ -87,7 +87,7 @@ treeherder.controller('TCJobActionsCtrl', [
});
});
} else {
alert("No decision task id, can't find taskcluster actions");
alert("No decision task, can't find taskcluster actions");
}

}]);
55 changes: 23 additions & 32 deletions ui/js/models/resultsets_store.js
Expand Up @@ -333,7 +333,7 @@ treeherder.factory('ThResultSetStore', [
};

var addRunnableJobs = function(repoName, resultSet) {
getGeckoDecisionTaskID(repoName, resultSet.id).then(function(decisionTaskId) {
getGeckoDecisionTaskId(repoName, resultSet.id).then(function(decisionTaskId) {
if (repoName !== "try") {
decisionTaskId = "";
}
Expand All @@ -353,8 +353,8 @@ treeherder.factory('ThResultSetStore', [
}, function() {
thNotify.send("Error fetching runnable jobs", "danger");
});
}, function() {
thNotify.send("Error fetching runnable jobs: Failed to fetch task ID", "danger");
}, function(reason) {
thNotify.send(`Error fetching runnable jobs: Failed to fetch task ID (${reason})`, "danger");
});
};

Expand Down Expand Up @@ -930,7 +930,7 @@ treeherder.factory('ThResultSetStore', [
return repositories[repoName].rsMap[resultsetId].selected_runnable_jobs;
};

var getGeckoDecisionTaskGUID = function(repoName, resultsetId) {
var getGeckoDecisionJob = function(repoName, resultsetId) {
let resultSet = getResultSet(repoName, resultsetId);
let platform = _.find(resultSet.platforms, {
"name": "gecko-decision",
Expand All @@ -939,45 +939,36 @@ treeherder.factory('ThResultSetStore', [
// Gecko Decision Task has been completed.
// Let's fetch the URL of full-tasks-graph.json
// This extra search is important to avoid confusion with Action Tasks
let decisionTask = _.find(platform.groups[0].jobs, {"job_type_symbol": "D"});

return decisionTask.job_guid;
return _.find(platform.groups[0].jobs, {"job_type_symbol": "D"});
}

return undefined;
};

var getGeckoDecisionTaskID = function(repoName, resultsetId) {
var getGeckoDecisionTaskId = function(repoName, resultsetId) {
let resultSet = getResultSet(repoName, resultsetId);
let dtid = resultSet.geckoDecisionTaskID;
let dtid = resultSet.geckoDecisionTaskId;
// If we've retrieved it already, we can just return it again. Otherwise
// try to find it. If it doesn't exist, we set it to an empty string.
if (dtid || dtid === "") {
return $q.when(dtid);
}

let tcURLPromise;
let decisionTaskGUID = getGeckoDecisionTaskGUID(repoName, resultsetId);
if (decisionTaskGUID) {
tcURLPromise = ThJobDetailModel.getJobDetails({job_guid: decisionTaskGUID},
{timeout: null});
}
if (!tcURLPromise) {
// Here we are passing false to the results instead of skipping the promise
tcURLPromise = $q.when(false);
let decisionTask = getGeckoDecisionJob(repoName, resultsetId);
if (decisionTask) {
return ThJobModel.get(repoName, decisionTask.id).then(
function(job) {
// this failure case is unlikely, but I guess you
// never know
if (!job.taskcluster_metadata) {
return $q.reject("Decision task missing taskcluster metadata");
}
return job.taskcluster_metadata.task_id;
});
}
return tcURLPromise.then(function(results) {
// Since we want to try this only on try first
var decisionTaskID = "";
if (results) {
var inspectTask = _.filter(results, {"title": "Inspect Task"})[0];
decisionTaskID = inspectTask.url.substring(inspectTask.url.indexOf("#") + 1);
// Removing last two characters /0
decisionTaskID = decisionTaskID.substring(0, decisionTaskID.lastIndexOf('/'));
}
resultSet.geckoDecisionTaskID = decisionTaskID;
return decisionTaskID;
});

// no decision task, we fail
return $q.reject("No decision task");
};

var toggleSelectedRunnableJob = function(repoName, resultsetId, buildername) {
Expand Down Expand Up @@ -1278,8 +1269,8 @@ treeherder.factory('ThResultSetStore', [
addRunnableJobs: addRunnableJobs,
isRunnableJobSelected: isRunnableJobSelected,
getSelectedRunnableJobs: getSelectedRunnableJobs,
getGeckoDecisionTaskGUID: getGeckoDecisionTaskGUID,
getGeckoDecisionTaskID: getGeckoDecisionTaskID,
getGeckoDecisionJob: getGeckoDecisionJob,
getGeckoDecisionTaskId: getGeckoDecisionTaskId,
toggleSelectedRunnableJob: toggleSelectedRunnableJob,
getResultSet: getResultSet,
getResultSetsArray: getResultSetsArray,
Expand Down

0 comments on commit 9ff7e98

Please sign in to comment.