Commit d0cddd04 authored by Daniel Smith's avatar Daniel Smith

Bugfixes

parent 4e463b12
...@@ -156,7 +156,7 @@ class jobNotificationHandler { ...@@ -156,7 +156,7 @@ class jobNotificationHandler {
let _this = this; let _this = this;
if (!_this.globals.locked) { if (!_this.globals.locked) {
_this.globals.locked = true; // Lock out other jobs from trying to run. _this.globals.locked = true; // Lock out other jobs from trying to run.
_this.globals.runningJob = _this.globals.jobQueue.pop(); // Grab a job from the queue _this.globals.runningJob = _this.globals.queuedJobs.pop(); // Grab a job from the queue
_this.globals.runningJob.status = "running"; _this.globals.runningJob.status = "running";
_this.globals.runningJob.status_msg = "Launching new build process"; _this.globals.runningJob.status_msg = "Launching new build process";
_this.globals.runningJob.startTime = Date.now(); _this.globals.runningJob.startTime = Date.now();
...@@ -286,7 +286,7 @@ class jobNotificationHandler { ...@@ -286,7 +286,7 @@ class jobNotificationHandler {
// the same exact job twice (including the timestamp on it) // the same exact job twice (including the timestamp on it)
if ( if (
_this.globals.runningJob.jobHash === jobHash || _this.globals.runningJob.jobHash === jobHash ||
_this.globals.jobQueue.findIndex((x) => x.jobHash == jobHash) >= 0 _this.globals.queuedJobs.findIndex((x) => x.jobHash == jobHash) >= 0
) { ) {
console.log("Returning error. Job already exists."); console.log("Returning error. Job already exists.");
if (!_this.globals.isPrimaryHost) { if (!_this.globals.isPrimaryHost) {
...@@ -303,7 +303,7 @@ class jobNotificationHandler { ...@@ -303,7 +303,7 @@ class jobNotificationHandler {
// Each server keeps an expected duration for each type // Each server keeps an expected duration for each type
// of job so we can give more accurate estimates. // of job so we can give more accurate estimates.
job.expectedDuration = _this.globals.expectedDurations[job.testType]; job.expectedDuration = _this.globals.expectedDurations[job.testType];
_this.globals.jobQueue.push(job); _this.globals.queuedJobs.push(job);
if (job.remote_job) if (job.remote_job)
res.send(job); // Send the completed job object to the scheduler. res.send(job); // Send the completed job object to the scheduler.
else else
...@@ -403,7 +403,7 @@ class jobNotificationHandler { ...@@ -403,7 +403,7 @@ class jobNotificationHandler {
job.status = "cancelled"; job.status = "cancelled";
_this.globals.completedJobs.push(job); _this.globals.completedJobs.push(job);
// pop the queued job out of the queue. // pop the queued job out of the queue.
_this.globals.jobQueue.splice(_this.globals.jobQueue.findIndex((x) => x.jobHash == job.jobHash)); _this.globals.queuedJobs.splice(_this.globals.queuedJobs.findIndex((x) => x.jobHash == job.jobHash));
if (job.remote_job) { if (job.remote_job) {
console.log(`Preparing to send update to master host about cancelled jobHash ${job.jobHash}`); console.log(`Preparing to send update to master host about cancelled jobHash ${job.jobHash}`);
......
...@@ -32,7 +32,7 @@ let globals ={ ...@@ -32,7 +32,7 @@ let globals ={
path: os.platform() === "win32" ? "c:" : "/", path: os.platform() === "win32" ? "c:" : "/",
updateLockout: false, updateLockout: false,
hosts: [], hosts: [],
jobQueue: [], queuedJobs: [],
runningJob: {}, runningJob: {},
remoteRunningJobs: [], remoteRunningJobs: [],
remoteQueuedJobs: [], remoteQueuedJobs: [],
...@@ -105,9 +105,6 @@ if (globals.standalone && globals.nolocal) { ...@@ -105,9 +105,6 @@ if (globals.standalone && globals.nolocal) {
console.log(`Have agents: ${globals.agents}`); console.log(`Have agents: ${globals.agents}`);
} }
if (globals.agents)
globals.isPrimaryHost = true;
console.log(`I am ${globals.isPrimaryHost ? "" : "not "}a primary host, and I ${ console.log(`I am ${globals.isPrimaryHost ? "" : "not "}a primary host, and I ${
globals.nolocal ? "will not" : "will"} run local jobs.`); globals.nolocal ? "will not" : "will"} run local jobs.`);
...@@ -157,7 +154,7 @@ notifyJob.on("finishedScheduling", function (req, res) { ...@@ -157,7 +154,7 @@ notifyJob.on("finishedScheduling", function (req, res) {
function queryJobs(req, res) { function queryJobs(req, res) {
// We're a remote host and the scheduler asked us for our jobs. Give it to 'em! // We're a remote host and the scheduler asked us for our jobs. Give it to 'em!
console.log("Sending current running and queued job list..."); console.log("Sending current running and queued job list...");
console.log(`${JSON.stringify({ runningJob: globals.runningJob.jobHash, queuedJobs: globals.jobQueue })}`); console.log(`${JSON.stringify({ runningJob: globals.runningJob.jobHash, queuedJobs: globals.queuedJobs })}`);
// Create a temporary job object that we'll send because stringifying // Create a temporary job object that we'll send because stringifying
// a process handle of the running process will fail in a very nasty // a process handle of the running process will fail in a very nasty
...@@ -194,9 +191,9 @@ function queryJobs(req, res) { ...@@ -194,9 +191,9 @@ function queryJobs(req, res) {
master_host: globals.runningJob.master_host master_host: globals.runningJob.master_host
}; };
if (res) if (res)
res.send({ runningJob: tempRunningJob, queuedJobs: globals.jobQueue }); res.send({ runningJob: tempRunningJob, queuedJobs: globals.queuedJobs });
else else
return { runningJob: tempRunningJob, queuedJobs: globals.jobQueue }; return { runningJob: tempRunningJob, queuedJobs: globals.queuedJobs };
} }
function serveJobsJSON(req, res) { function serveJobsJSON(req, res) {
...@@ -262,10 +259,10 @@ function cancelJob(req, res) { ...@@ -262,10 +259,10 @@ function cancelJob(req, res) {
if (req.query.jobHash === globals.runningJob.jobHash) { if (req.query.jobHash === globals.runningJob.jobHash) {
console.log("Cancelling local running job"); console.log("Cancelling local running job");
notifyJob.emit("cancel", globals.runningJob, req, res); notifyJob.emit("cancel", globals.runningJob, req, res);
} else if (globals.jobQueue[globals.jobQueue.findIndex((x) => x.jobHash == req.query.jobHash)]) { } else if (globals.queuedJobs[globals.queuedJobs.findIndex((x) => x.jobHash == req.query.jobHash)]) {
console.log("Cancelling local queued job"); console.log("Cancelling local queued job");
notifyJob.emit( notifyJob.emit(
"cancel", globals.jobQueue[globals.jobQueue.findIndex((x) => x.jobHash == req.query.jobHash)], "cancel", globals.queuedJobs[globals.queuedJobs.findIndex((x) => x.jobHash == req.query.jobHash)],
req, res req, res
); );
} else { } else {
...@@ -369,7 +366,7 @@ function serveHomePage(req, res) { ...@@ -369,7 +366,7 @@ function serveHomePage(req, res) {
readyChecklist.localJobs = true; readyChecklist.localJobs = true;
readyEmitter.emit('readyCheck'); readyEmitter.emit('readyCheck');
} }
if (globals.jobQueue.length != 0) { if (globals.queuedJobs.length != 0) {
view.queuedJobs += "<h4>Queued:</h4><ul>"; view.queuedJobs += "<h4>Queued:</h4><ul>";
toolbox.addJobRecursive(view.queuedJobs, globals.queuedJobs.slice().reverse(), 0, (formatted) => { toolbox.addJobRecursive(view.queuedJobs, globals.queuedJobs.slice().reverse(), 0, (formatted) => {
view.queuedJobs = formatted; view.queuedJobs = formatted;
...@@ -393,7 +390,7 @@ function serveHomePage(req, res) { ...@@ -393,7 +390,7 @@ function serveHomePage(req, res) {
// Only display remote running jobs if there are any // Only display remote running jobs if there are any
if (globals.remoteRunningJobs.length != 0) { if (globals.remoteRunningJobs.length != 0) {
view.remoteJobs += "<h4>Running:</h4><ul>"; view.remoteJobs += "<h4>Running:</h4><ul>";
toolbox.addJobRecursive(view.remoteJobs, globals.remoteJobs.slice().reverse(), 0, (formatted) => { toolbox.addJobRecursive(view.remoteJobs, globals.remoteRunningJobs.slice().reverse(), 0, (formatted) => {
view.remoteJobs = formatted; view.remoteJobs = formatted;
view.remoteJobs += "</ul></br>"; view.remoteJobs += "</ul></br>";
readyChecklist.remoteJobs = true; readyChecklist.remoteJobs = true;
...@@ -621,7 +618,7 @@ function runServer() { ...@@ -621,7 +618,7 @@ function runServer() {
server.get("/clearRecentErrors", (req, res) => clearErrors(req, res)); server.get("/clearRecentErrors", (req, res) => clearErrors(req, res));
server.get("/clearFinishedJobs", (req, res) => clearFinishedJobs(req, res)); server.get("/clearFinishedJobs", (req, res) => clearFinishedJobs(req, res));
server.get("/status", (req, res) => serveStatus(req, res)); server.get("/status", (req, res) => serveStatus(req, res));
server.get("/", (req, res) => serveHomePage(req, res)); server.all("/", (req, res) => serveHomePage(req, res));
console.log(`Starting server... Listening on port ${globals.webPort}`); console.log(`Starting server... Listening on port ${globals.webPort}`);
......
...@@ -204,7 +204,7 @@ class testHandler { ...@@ -204,7 +204,7 @@ class testHandler {
if (job.remote_job) { if (job.remote_job) {
_this.notifyJob.emit("updateRemoteJob", job, "finished"); // Notify scheduler _this.notifyJob.emit("updateRemoteJob", job, "finished"); // Notify scheduler
if (_this.globals.jobQueue.length != 0) { if (_this.globals.queuedJobs.length != 0) {
// Delay starting the next job for a few seconds to // Delay starting the next job for a few seconds to
// prevent race conditions and make a better UI experience. // prevent race conditions and make a better UI experience.
setTimeout(function () { setTimeout(function () {
...@@ -212,7 +212,7 @@ class testHandler { ...@@ -212,7 +212,7 @@ class testHandler {
}, 3000); }, 3000);
} }
} else { } else {
if (_this.globals.jobQueue.length != 0) if (_this.globals.queuedJobs.length != 0)
_this.notifyJob.emit("newLocalJob"); // If we're not acting as a remote host, we can just execute immediately. _this.notifyJob.emit("newLocalJob"); // If we're not acting as a remote host, we can just execute immediately.
} }
if (validator.validate(job.owner)) { if (validator.validate(job.owner)) {
......
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