From 029f4d8b31ff49c920404669f80f894da0956ed1 Mon Sep 17 00:00:00 2001 From: Jenia White Date: Mon, 30 Mar 2020 15:44:40 +0300 Subject: [PATCH] Fixing deletion of OBCs (cherry picked from commit 8552d2121d955d85d2597392b61632570272915b) --- src/server/bg_services/buckets_reclaimer.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server/bg_services/buckets_reclaimer.js b/src/server/bg_services/buckets_reclaimer.js index 5d7b14a7f4..232f8ce56d 100644 --- a/src/server/bg_services/buckets_reclaimer.js +++ b/src/server/bg_services/buckets_reclaimer.js @@ -7,6 +7,7 @@ const system_store = require('../system_services/system_store').get_instance(); const system_utils = require('../utils/system_utils'); const P = require('../../util/promise'); const auth_server = require('../common_services/auth_server'); +const _ = require('lodash'); class BucketsReclaimer { @@ -18,6 +19,7 @@ class BucketsReclaimer { async run_batch() { if (!this._can_run()) return; + const support_account = _.find(system_store.data.accounts, account => account.is_support); const deleting_buckets = this._get_deleting_buckets(); if (!deleting_buckets || !deleting_buckets.length) { dbg.log0('no buckets in "deleting" state. nothing to do'); @@ -36,6 +38,7 @@ class BucketsReclaimer { }, { auth_token: auth_server.make_auth_token({ system_id: system_store.data.systems[0]._id, + account_id: support_account._id, role: 'admin' }) }); @@ -44,6 +47,7 @@ class BucketsReclaimer { await this.client.bucket.delete_bucket({ name: bucket.name, internal_call: true }, { auth_token: auth_server.make_auth_token({ system_id: system_store.data.systems[0]._id, + account_id: support_account._id, role: 'admin' }) }); @@ -72,6 +76,9 @@ class BucketsReclaimer { const system = system_store.data.systems[0]; if (!system || system_utils.system_in_maintenance(system._id)) return false; + const support_account = _.find(system_store.data.accounts, account => account.is_support); + if (!support_account) return false; + return true; }