Skip to content

Commit

Permalink
NC | account by id | fixes to upgrade script - remove buckets
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Prinz Setter <[email protected]>
  • Loading branch information
alphaprinz committed Jul 30, 2024
1 parent 3bd76a3 commit 4be39ac
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions src/upgrade/upgrade_scripts/5.18.0/upgrade_conf_518.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
'use strict';

const minimist = require('minimist');
const {statSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, symlinkSync, rmSync, writeFileSync} = require('fs');
const {statSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, symlinkSync, rmSync} = require('fs');
const {join} = require('path');
const { CONFIG_SUBDIRS } = require('../manage_nsfs/manage_nsfs_constants');
const config = require('../../config');
const { CONFIG_SUBDIRS } = require('../../../manage_nsfs/manage_nsfs_constants');
const config = require('../../../../config');

const dbg = require('../util/debug_module')(__filename);
const dbg = require('../../../util/debug_module')(__filename);

const account_id_to_name = new Map();

Expand Down Expand Up @@ -113,27 +113,6 @@ function map_account_id_to_name(dir_ent) {
return 0;
}

function handle_bucket_file(dir_ent) {
const filename = join(dir_ent.parentPath, dir_ent.name);
if (!filename.endsWith(".json")) {
dbg.warn("File in bucket dir is not a json file. Filename = ", filename);
return 2;
}

let bucket_str = readFileSync(filename);
const bucket = JSON.parse(bucket_str);

bucket.system_owner = bucket.owner_account;
delete bucket.bucket_owner;

dbg.log("Updating bucket ", filename);
rmSync(filename);
bucket_str = JSON.stringify(bucket);
writeFileSync(filename, bucket_str);

return 0;
}

function run({conf_path}) {

conf_path = conf_path || config.NSFS_NC_CONF_DIR;
Expand Down Expand Up @@ -178,15 +157,6 @@ function run({conf_path}) {
}
}

//upgrade buckets
const bucket_files = readdirSync(bucket_dir, {withFileTypes: true});
for (const bucket_file of bucket_files) {
const res = handle_bucket_file(bucket_file);
if (res !== 0) {
return res;
}
}

dbg.log("Completed successfully.");
return 0;
}
Expand Down

0 comments on commit 4be39ac

Please sign in to comment.