aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pod
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/pod')
-rw-r--r--server/models/pod/pod.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts
index e4d7db48a..6619726af 100644
--- a/server/models/pod/pod.ts
+++ b/server/models/pod/pod.ts
@@ -247,20 +247,21 @@ updatePodsScore = function (goodPods: number[], badPods: number[]) {
247// --------------------------------------------------------------------------- 247// ---------------------------------------------------------------------------
248 248
249// Remove pods with a score of 0 (too many requests where they were unreachable) 249// Remove pods with a score of 0 (too many requests where they were unreachable)
250function removeBadPods () { 250async function removeBadPods () {
251 return listBadPods() 251 try {
252 .then(pods => { 252 const pods = await listBadPods()
253 const podsRemovePromises = pods.map(pod => pod.destroy()) 253
254 return Promise.all(podsRemovePromises).then(() => pods.length) 254 const podsRemovePromises = pods.map(pod => pod.destroy())
255 }) 255 await Promise.all(podsRemovePromises)
256 .then(numberOfPodsRemoved => { 256
257 if (numberOfPodsRemoved) { 257 const numberOfPodsRemoved = pods.length
258 logger.info('Removed %d pods.', numberOfPodsRemoved) 258
259 } else { 259 if (numberOfPodsRemoved) {
260 logger.info('No need to remove bad pods.') 260 logger.info('Removed %d pods.', numberOfPodsRemoved)
261 } 261 } else {
262 }) 262 logger.info('No need to remove bad pods.')
263 .catch(err => { 263 }
264 logger.error('Cannot remove bad pods.', err) 264 } catch (err) {
265 }) 265 logger.error('Cannot remove bad pods.', err)
266 }
266} 267}