Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid throwing an error in tier_server.update_bucket_class #8173

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/server/system_services/tier_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const node_allocator = require('../node_services/node_allocator');
const system_store = require('./system_store').get_instance();
const chunk_config_utils = require('../utils/chunk_config_utils');
const SensitiveString = require('../../util/sensitive_string');
const P = require('../../util/promise');

function new_tier_defaults(name, system_id, chunk_config, mirrors, storage_class) {
return _.omitBy({
Expand Down Expand Up @@ -357,7 +358,12 @@ async function update_bucket_class(req) {
.map(obj => obj.tier.name);
for (const [index, tier] of tiers.entries()) {
const old_tier = old_tiers[index];
const new_name = `${bucket.name.unwrap()}.${Math.round(Date.now() / 1000)}.${index}`;
let new_name = `${bucket.name.unwrap()}.${Date.now()}.${index}`;
// regenerate new_name if it already exists
while (req.system.tiers_by_name && req.system.tiers_by_name[name]) {
await P.delay(1);
new_name = `${bucket.name.unwrap()}.${Date.now()}.${index}`;
}
policy.tiers[index].tier = new_name;
const pool_ids = _.map(tier.attached_pools,
pool_name => req.system.pools_by_name[pool_name]._id
Expand All @@ -370,7 +376,6 @@ async function update_bucket_class(req) {
changes.insert.chunk_configs.push(chunk_config);
update_db = true;
}
check_tier_exists(req, new_name);
const new_tier = new_tier_defaults(
new_name,
req.system._id,
Expand Down