Commit 1cfcb436 authored by Daniel Smith's avatar Daniel Smith

Bugfix remote job query

parent 3313c70b
......@@ -53,7 +53,7 @@ POST 127.0.0.1:8080/remoteSchedule
commit: '49ffc6e6af83b295c67fd119b79c925879cc292e',
test_name: 'auto/creation/quick.controls2/delegates_combobox.qml',
test_hosts: 'myTestHost1',
patches: '39d99c714bb87bd39e92d85fb1f46c52eb9f8d33,5bdf48f6c9e125c2528e3af16eda257ab0fef9c0'
patches: '086ca457b524d826af5fc5e184bd8f649c431c21,refs/changes/39/306639/4'
}
```
......
......@@ -270,14 +270,16 @@ function cancelJob(req, res) {
} else {
// Job must be remote. Forward the cancel request to the agent.
let jobFound = false;
[global.remoteRunningJobs, global.remoteQueuedJobs].forEach((targetArray) => {
let targetIndex = -1;
toolbox.getIndex(targetArray, req.query.jobHash);
[globals.remoteRunningJobs, globals.remoteQueuedJobs].forEach((targetArray) => {
let targetIndex = toolbox.getIndex(targetArray, req.query.jobHash);
if (targetIndex == -1) {
return;
} else {
jobFound = true;
let remoteIP = globals.hosts[globals.hosts.findIndex((x) => x.hostname ==targetArray[targetIndex].test_hosts[0])].ip
let remoteIP =
globals.hosts[
globals.hosts.findIndex((x) => x.hostname == targetArray[targetIndex].test_hosts[0])
].ip
axios.get(`http://${remoteIP}:${globals.webPort}/cancelJob?jobHash=${req.query.jobHash}`, { timeout: 2000 })
.then((response) => {
// Delay the redirect to the remote host might have time to update the job before we refresh the page for the user.
......
......@@ -30,14 +30,13 @@ let smtpPort = envOrConfig(Number("SMTP_PORT"));
exports.getIndex = getIndex;
function getIndex(targetArray, jobHash) {
let index = -1;
// Use Try/Catch here since it's possible
// targetArray could be undefined.
try {
index = targetArray[targetArray.findIndex((j) => j.jobHash == jobHash)]
return targetArray.findIndex((j) => j.jobHash == jobHash)
} catch (exception) {
console.log(exception)
return index;
return -1;
}
return index;
}
exports.addJobToArray = addJobToArray;
......
......@@ -14,11 +14,12 @@
table {
border: 1px solid black;
border-spacing: 0px;
}
th {
text-align: center;
border: 1px solid black;
border-bottom: 1px solid black;
padding-left: 15px;
padding-right: 15px;
}
......@@ -27,7 +28,6 @@
padding-left: 15px;
padding-right: 15px;
text-align: center;
border: 1px solid black;
}
.failed {
......@@ -262,13 +262,17 @@
bug / request feature</button>
<br>
<div align="center">
<button onclick="window.location.href='/scheduleJob'">Schedule new job</button>
<button onclick="window.location.href='/refreshRemoteJobs'" style="display:{{displayStyle}}">Refresh Remote
Jobs</button>
<button onclick="window.location.href='/logs'">Browse log directory</button>
<button onclick="window.location.href='/recentErrors'" style="background-color:{{errorsButtonBgColor}}">Recent
system errors
({{recentErrorsCount}})</button>
<table style="border:0px;">
<tr>
<td><button onclick="window.location.href='/scheduleJob'">Schedule new job</button></td>
<td><button onclick="window.location.href='/logs'">Browse log directory</button></td>
<td style="display:{{displayStyle}}"><button onclick="window.location.href='/refreshRemoteJobs'">Refresh Remote
Jobs</button></td>
<td><button onclick="window.location.href='/recentErrors'" style="background-color:{{errorsButtonBgColor}}">Recent
system errors
({{recentErrorsCount}})</button></td>
</tr>
</table>
</div>
<br>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment