Skip to content

Commit

Permalink
Fixing deletion of OBCs
Browse files Browse the repository at this point in the history
(cherry picked from commit 8552d21)
  • Loading branch information
jeniawhite authored and nimrod-becker committed Mar 30, 2020
1 parent 9440626 commit 029f4d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/server/bg_services/buckets_reclaimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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');
Expand All @@ -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'
})
});
Expand All @@ -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'
})
});
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 029f4d8

Please sign in to comment.