@@ -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 }
0 commit comments