Skip to content

Commit

Permalink
Merge pull request #57 from pierotofy/vacuumoffline
Browse files Browse the repository at this point in the history
Vacuum offline ASR nodes
  • Loading branch information
pierotofy authored Jul 11, 2020
2 parents 420895b + 8127b52 commit ba612ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions libs/asrProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,33 @@ module.exports = {
},

vacuum: async function(){
const autoNodes = nodes.filter(n => n.isAutoSpawned() && n.isOnline());
const autoNodes = nodes.filter(n => n.isAutoSpawned());

// Automatically remove autospawned nodes if either:
// - They have been online for too long (stuck?)
// - They have an empty queue and are past their allowed upload time

// - They are online and have an empty queue and are past their allowed upload time
// - They are offline and have been offline for too long (past the maximum allowed upload time)
const now = new Date().getTime();
const cleanNodes = [];

autoNodes.forEach(n => {
if (n.getDockerMachineMaxRuntime() > 0 && (now - n.getDockerMachineCreated()) > n.getDockerMachineMaxRuntime() * 1000){
logger.warn(`${n} has exceeded its maximum runtime and will be forcibly deleted!`)
cleanNodes.push(n);
if (n.isOnline()){
if (n.getDockerMachineMaxRuntime() > 0 && (now - n.getDockerMachineCreated()) > n.getDockerMachineMaxRuntime() * 1000){
logger.warn(`${n} has exceeded its maximum runtime and will be forcibly deleted!`)
cleanNodes.push(n);
}else{
if (n.getDockerMachineMaxUploadTime() > 0 &&
n.getInfoProperty("taskQueueCount", 0) === 0 &&
(now - n.getDockerMachineCreated()) > n.getDockerMachineMaxUploadTime() * 1000){
logger.warn(`${n} has exceeded its maximum upload time and will be forcibly deleted!`)
cleanNodes.push(n);
}
}
}else{
// Offline
if (n.getDockerMachineMaxUploadTime() > 0 &&
n.getInfoProperty("taskQueueCount", 0) === 0 &&
(now - n.getDockerMachineCreated()) > n.getDockerMachineMaxUploadTime() * 1000){
logger.warn(`${n} has exceeded its maximum upload time and will be forcibly deleted!`)
(now - n.getLastRefreshed()) > n.getDockerMachineMaxUploadTime() * 1000){
logger.warn(`${n} has been offline for too long and will be forcibly deleted!`)
cleanNodes.push(n);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ClusterODM",
"version": "1.4.2",
"version": "1.4.3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ba612ab

Please sign in to comment.