Commit d0cddd04 authored by Daniel Smith's avatar Daniel Smith

Bugfixes

parent 4e463b12
......@@ -156,7 +156,7 @@ class jobNotificationHandler {
let _this = this;
if (!_this.globals.locked) {
_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_msg = "Launching new build process";
_this.globals.runningJob.startTime = Date.now();
......@@ -286,7 +286,7 @@ class jobNotificationHandler {
// the same exact job twice (including the timestamp on it)
if (
_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.");
if (!_this.globals.isPrimaryHost) {
......@@ -303,7 +303,7 @@ class jobNotificationHandler {
// Each server keeps an expected duration for each type
// of job so we can give more accurate estimates.
job.expectedDuration = _this.globals.expectedDurations[job.testType];
_this.globals.jobQueue.push(job);
_this.globals.queuedJobs.push(job);
if (job.remote_job)
res.send(job); // Send the completed job object to the scheduler.
else
......@@ -403,7 +403,7 @@ class jobNotificationHandler {
job.status = "cancelled";
_this.globals.completedJobs.push(job);
// 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) {
console.log(`Preparing to send update to master host about cancelled jobHash ${job.jobHash}`);
......
......@@ -32,7 +32,7 @@ let globals ={
path: os.platform() === "win32" ? "c:" : "/",
updateLockout: false,
hosts: [],
jobQueue: [],
queuedJobs: [],
runningJob: {},
remoteRunningJobs: [],
remoteQueuedJobs: [],
......@@ -105,9 +105,6 @@ if (globals.standalone && globals.nolocal) {
console.log(`Have agents: ${globals.agents}`);
}
if (globals.agents)
globals.isPrimaryHost = true;
console.log(`I am ${globals.isPrimaryHost ? "" : "not "}a primary host, and I ${
globals.nolocal ? "will not" : "will"} run local jobs.`);
......@@ -157,7 +154,7 @@ notifyJob.on("finishedScheduling", function (req, res) {
function queryJobs(req, res) {
// 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(`${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
// a process handle of the running process will fail in a very nasty
......@@ -194,9 +191,9 @@ function queryJobs(req, res) {
master_host: globals.runningJob.master_host
};
if (res)
res.send({ runningJob: tempRunningJob, queuedJobs: globals.jobQueue });
res.send({ runningJob: tempRunningJob, queuedJobs: globals.queuedJobs });
else
return { runningJob: tempRunningJob, queuedJobs: globals.jobQueue };
return { runningJob: tempRunningJob, queuedJobs: globals.queuedJobs };
}
function serveJobsJSON(req, res) {
......@@ -262,10 +259,10 @@ function cancelJob(req, res) {
if (req.query.jobHash === globals.runningJob.jobHash) {
console.log("Cancelling local running job");
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");
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
);
} else {
......@@ -369,7 +366,7 @@ function serveHomePage(req, res) {
readyChecklist.localJobs = true;
readyEmitter.emit('readyCheck');
}
if (globals.jobQueue.length != 0) {
if (globals.queuedJobs.length != 0) {
view.queuedJobs += "<h4>Queued:</h4><ul>";
toolbox.addJobRecursive(view.queuedJobs, globals.queuedJobs.slice().reverse(), 0, (formatted) => {
view.queuedJobs = formatted;
......@@ -393,7 +390,7 @@ function serveHomePage(req, res) {
// Only display remote running jobs if there are any
if (globals.remoteRunningJobs.length != 0) {
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 += "</ul></br>";
readyChecklist.remoteJobs = true;
......@@ -621,7 +618,7 @@ function runServer() {
server.get("/clearRecentErrors", (req, res) => clearErrors(req, res));
server.get("/clearFinishedJobs", (req, res) => clearFinishedJobs(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}`);
......
......@@ -204,7 +204,7 @@ class testHandler {
if (job.remote_job) {
_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
// prevent race conditions and make a better UI experience.
setTimeout(function () {
......@@ -212,7 +212,7 @@ class testHandler {
}, 3000);
}
} 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.
}
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