Skip to content

Commit f779b82

Browse files
committed
NC | List bucket do not retun full bucket name with .json suffix
Signed-off-by: naveenpaul1 <napaul@redhat.com>
1 parent fed847e commit f779b82

File tree

4 files changed

+119
-3
lines changed

4 files changed

+119
-3
lines changed

docs/NooBaaNonContainerized/NooBaaCLI.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,4 +838,57 @@ sudo noobaa-cli connection add --from_file <options_connection_JSON_file_path>
838838
### White List Server IP command example
839839
```
840840
sudo noobaa-cli whitelist --ips ["127.0.0.1", "192.0.10.0", "3002:0bd6:0000:0000:0000:ee00:0033:6778"]'
841-
```
841+
```
842+
843+
### Known issues
844+
845+
1. Bucket with suffix `.json`
846+
847+
When the customer creates a bucket with the suffix `.json`, suffix is removed from the bucket config file name.
848+
849+
For example
850+
```
851+
sudo noobaa-cli bucket add --name my-bucket1.json --owner <owner_name> --path <path>
852+
```
853+
Actual file name : `{config_root}\buckets\my-test-bucket.json`
854+
855+
Expected file name : `{config_root}\buckets\my-test-bucket.json.json`
856+
857+
I/O is not possible in this bucket. This issue is only reproducible in older versions(5.18.0 and older).
858+
Issue fixed version is <TBD>
859+
860+
solution :
861+
* Recreate the bucket with same name in new version
862+
```
863+
sudo noobaa-cli bucket add --name my-bucket1.json --owner <owner_name> --path <path>
864+
```
865+
* Delete invalid bucket
866+
```
867+
bucket delete --name my-bucket1 (bucket name without suffix `.json`)
868+
```
869+
870+
2. Account with suffix `.symlink`
871+
872+
When the customer creates an account with the suffix `.symlink`, suffix is removed from the account config file name.
873+
874+
For example
875+
```
876+
sudo noobaa-cli account add --name acc_symlink.symlink --new_buckets_path <path> --uid <uid> --gid <gid>
877+
```
878+
Actual file name : `{config_root}\accounts_by_name\acc_symlink.symlink`
879+
880+
Expected file name : `{config_root}\accounts_by_name\acc_symlink.symlink.symlink`
881+
882+
This issue is only reproducible in older versions(5.18.0 and older).
883+
Issue fixed version is <TBD>
884+
885+
solution :
886+
* Recreate the account with same name in new version
887+
```
888+
sudo noobaa-cli account add --name acc_symlink.symlink --new_buckets_path <path> --uid <uid> --gid <gid>
889+
```
890+
* Delete invalid account
891+
```
892+
sudo noobaa-cli account delete --name acc_symlink (account name without suffix `.symlink`)
893+
```
894+

src/sdk/config_fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ class ConfigFS {
103103

104104
/**
105105
* add_config_file_suffix returns the config_file_name follwed by the given suffix
106+
* Bucket name can have suffix `.json`. This will make sure the bucket name and bucket config file have the same name.
106107
* @param {string} config_file_name
107108
* @param {string} suffix
108109
* @returns {string}
109110
*/
110111
add_config_file_suffix(config_file_name, suffix) {
111112
if (!config_file_name) dbg.warn(`Config file name is missing - ${config_file_name}`);
112-
if (String(config_file_name).endsWith(suffix)) return config_file_name;
113113
return config_file_name + suffix;
114114
}
115115

src/test/unit_tests/jest_tests/test_nc_account_cli.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,46 @@ describe('manage nsfs cli account flow', () => {
603603
const res = await exec_manage_cli(type, action, account_options);
604604
expect(JSON.parse(res.stdout).error.code).toBe(ManageCLIError.InvalidSupplementalGroupsList.code);
605605
});
606+
607+
it('cli account add - with account name suffix `.json`', async function() {
608+
const action = ACTIONS.ADD;
609+
const { type, new_buckets_path, uid, gid } = defaults;
610+
await fs_utils.create_fresh_path(new_buckets_path);
611+
await fs_utils.file_must_exist(new_buckets_path);
612+
const name = 'account_suffix.json';
613+
const account_options = { config_root, name, new_buckets_path, uid, gid };
614+
const res = await exec_manage_cli(type, action, account_options);
615+
const parse_res = JSON.parse(res);
616+
expect(parse_res.response.code).toEqual(ManageCLIResponse.AccountCreated.code);
617+
expect(parse_res.response.reply.name).toEqual(name);
618+
const account = await config_fs.get_account_by_name(name);
619+
expect(account.name).toBe(name);
620+
const res1 = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.STATUS, { name, config_root });
621+
expect(JSON.parse(res1).response.reply.name).toBe(name);
622+
const res_list = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.LIST, { config_root });
623+
expect(JSON.parse(res_list).response.reply.map(item => item.name))
624+
.toEqual(expect.arrayContaining([name]));
625+
});
626+
627+
it('cli account add - with account name suffix `.symlink`', async function() {
628+
const action = ACTIONS.ADD;
629+
const { type, new_buckets_path, uid, gid } = defaults;
630+
await fs_utils.create_fresh_path(new_buckets_path);
631+
await fs_utils.file_must_exist(new_buckets_path);
632+
const name = 'account_suffix.symlink';
633+
const account_options = { config_root, name, new_buckets_path, uid, gid };
634+
const res = await exec_manage_cli(type, action, account_options);
635+
const parse_res = JSON.parse(res);
636+
expect(parse_res.response.code).toEqual(ManageCLIResponse.AccountCreated.code);
637+
expect(parse_res.response.reply.name).toEqual(name);
638+
const account = await config_fs.get_account_by_name(name);
639+
expect(account.name).toBe(name);
640+
const res1 = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.STATUS, { name, config_root });
641+
expect(JSON.parse(res1).response.reply.name).toBe(name);
642+
const res_list = await exec_manage_cli(TYPES.ACCOUNT, ACTIONS.LIST, { config_root });
643+
expect(JSON.parse(res_list).response.reply.map(item => item.name))
644+
.toEqual(expect.arrayContaining([name]));
645+
});
606646
});
607647

608648
describe('cli update account', () => {

src/test/unit_tests/jest_tests/test_nc_bucket_cli.test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('manage nsfs cli bucket flow', () => {
2727
const config_root = path.join(tmp_fs_path, 'config_root_manage_nsfs');
2828
const config_fs = new ConfigFS(config_root);
2929
const root_path = path.join(tmp_fs_path, 'root_path_manage_nsfs/');
30-
const bucket_storage_path = path.join(tmp_fs_path, 'root_path_manage_nsfs', 'bucket1');
30+
const bucket_storage_path = path.join(root_path, 'bucket1');
31+
const bucket_json_storage_path = path.join(root_path, 'bucket3.json');
3132
set_nc_config_dir_in_config(config_root);
3233

3334
const account_defaults = {
@@ -54,6 +55,12 @@ describe('manage nsfs cli bucket flow', () => {
5455
path: bucket_storage_path,
5556
};
5657

58+
const bucket_suffix_json = {
59+
name: 'bucket3.json',
60+
owner: account_defaults.name,
61+
path: bucket_json_storage_path,
62+
};
63+
5764
beforeEach(async () => {
5865
await fs_utils.create_fresh_path(root_path);
5966
await fs_utils.create_fresh_path(bucket_storage_path);
@@ -242,6 +249,22 @@ describe('manage nsfs cli bucket flow', () => {
242249
await assert_bucket(bucket, bucket_options, config_fs);
243250
expect(bucket.s3_policy).toStrictEqual(bucket_policy);
244251
});
252+
253+
it('cli create bucket - with bucket name suffix `.json`', async () => {
254+
await fs_utils.create_fresh_path(bucket_json_storage_path);
255+
await fs_utils.file_must_exist(bucket_json_storage_path);
256+
const action = ACTIONS.ADD;
257+
const bucket_options = { config_root, ...bucket_suffix_json };
258+
await exec_manage_cli(TYPES.BUCKET, action, bucket_options);
259+
const bucket = await config_fs.get_bucket_by_name(bucket_suffix_json.name);
260+
expect(bucket).toBeDefined();
261+
expect(bucket.name).toBe(bucket_options.name);
262+
const res = await exec_manage_cli(TYPES.BUCKET, ACTIONS.STATUS, { name: bucket_suffix_json.name, config_root });
263+
expect(JSON.parse(res).response.reply.name).toBe(bucket_options.name);
264+
const res_list = await exec_manage_cli(TYPES.BUCKET, ACTIONS.LIST, { config_root });
265+
expect(JSON.parse(res_list).response.reply.map(item => item.name))
266+
.toEqual(expect.arrayContaining([bucket_options.name]));
267+
});
245268
});
246269

247270
describe('cli create bucket using from_file', () => {

0 commit comments

Comments
 (0)