Skip to content

Commit 8127b52

Browse files
committed
Vacuum offline ASR nodes
1 parent 420895b commit 8127b52

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

libs/asrProvider.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,33 @@ module.exports = {
113113
},
114114

115115
vacuum: async function(){
116-
const autoNodes = nodes.filter(n => n.isAutoSpawned() && n.isOnline());
116+
const autoNodes = nodes.filter(n => n.isAutoSpawned());
117117

118118
// Automatically remove autospawned nodes if either:
119119
// - They have been online for too long (stuck?)
120-
// - They have an empty queue and are past their allowed upload time
121-
120+
// - They are online and have an empty queue and are past their allowed upload time
121+
// - They are offline and have been offline for too long (past the maximum allowed upload time)
122122
const now = new Date().getTime();
123123
const cleanNodes = [];
124124

125125
autoNodes.forEach(n => {
126-
if (n.getDockerMachineMaxRuntime() > 0 && (now - n.getDockerMachineCreated()) > n.getDockerMachineMaxRuntime() * 1000){
127-
logger.warn(`${n} has exceeded its maximum runtime and will be forcibly deleted!`)
128-
cleanNodes.push(n);
126+
if (n.isOnline()){
127+
if (n.getDockerMachineMaxRuntime() > 0 && (now - n.getDockerMachineCreated()) > n.getDockerMachineMaxRuntime() * 1000){
128+
logger.warn(`${n} has exceeded its maximum runtime and will be forcibly deleted!`)
129+
cleanNodes.push(n);
130+
}else{
131+
if (n.getDockerMachineMaxUploadTime() > 0 &&
132+
n.getInfoProperty("taskQueueCount", 0) === 0 &&
133+
(now - n.getDockerMachineCreated()) > n.getDockerMachineMaxUploadTime() * 1000){
134+
logger.warn(`${n} has exceeded its maximum upload time and will be forcibly deleted!`)
135+
cleanNodes.push(n);
136+
}
137+
}
129138
}else{
139+
// Offline
130140
if (n.getDockerMachineMaxUploadTime() > 0 &&
131-
n.getInfoProperty("taskQueueCount", 0) === 0 &&
132-
(now - n.getDockerMachineCreated()) > n.getDockerMachineMaxUploadTime() * 1000){
133-
logger.warn(`${n} has exceeded its maximum upload time and will be forcibly deleted!`)
141+
(now - n.getLastRefreshed()) > n.getDockerMachineMaxUploadTime() * 1000){
142+
logger.warn(`${n} has been offline for too long and will be forcibly deleted!`)
134143
cleanNodes.push(n);
135144
}
136145
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ClusterODM",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)