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