Skip to content

Commit a0b1e9d

Browse files
authored
Merge pull request #9271 from jackyalbo/jacky-nc-fixes
NC | Adding support of user bucket path
2 parents 89f64d8 + dae43d2 commit a0b1e9d

File tree

16 files changed

+203
-12
lines changed

16 files changed

+203
-12
lines changed

config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ config.NSFS_LIST_IGNORE_ENTRY_ON_EACCES = true;
10221022
// we will for now handle the same way also EINVAL error - for gpfs stat issues on list (.snapshots)
10231023
config.NSFS_LIST_IGNORE_ENTRY_ON_EINVAL = true;
10241024

1025+
config.NSFS_CUSTOM_BUCKET_PATH_HTTP_HEADER = 'x-noobaa-custom-bucket-path';
1026+
config.NSFS_CUSTOM_BUCKET_PATH_ALLOWED_LIST = ''; // colon separated list of paths prefixes
1027+
10251028
////////////////////////////
10261029
// NSFS NON CONTAINERIZED //
10271030
////////////////////////////

docs/NooBaaNonContainerized/AccountsAndBuckets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ See all available account properties - [NC Account Schema](../../src/server/syst
3838

3939
- `new_buckets_path` - When an account creates a bucket using the S3 protocol, NooBaa will create the underlying file system directory. This directory will be created under new_buckets_path. Note that the account must have read and write access to its `new_buckets_path`. Must be an absolute path.
4040

41+
- `custom_bucket_path_allowed_list` - When an account creates a bucket using the S3 protocol, He can override the default bucket path location (under new_buckets_path) using `x-noobaa-custom-bucket-path` HTTP header. This directory will be created only if this path will be under one of the provided allowed list paths in custom_bucket_path_allowed_list. Must be a list of absolute paths (divided by colons).
42+
4143
### Account configuration
4244
Currently, an account can be configured via NooBaa CLI, see - [NooBaa CLI](./NooBaaCLI.md).
4345

docs/NooBaaNonContainerized/NooBaaCLI.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The `account add` command is used to create a new account with customizable opti
7676
```sh
7777
noobaa-cli account add --name <account_name> --uid <uid> --gid <gid> [--user]
7878
[--new_buckets_path][--access_key][--secret_key][--fs_backend]
79-
[--allow_bucket_creation][--force_md5_etag][--anonymous][--from_file][--iam_operate_on_root_account][--default_connection]
79+
[--allow_bucket_creation][--force_md5_etag][--anonymous][--from_file][--iam_operate_on_root_account][--default_connection][--custom_bucket_path_allowed_list]
8080
```
8181
#### Flags -
8282
- `name` (Required)
@@ -140,6 +140,11 @@ noobaa-cli account add --name <account_name> --uid <uid> --gid <gid> [--user]
140140
- Type: String
141141
- Description: A default account for Kafka external servers. See bucket-notifications.md.
142142

143+
- `custom_bucket_path_allowed_list`
144+
- Type: String
145+
- Description: Specifies an allowed list where this account can create buckets in using
146+
x-noobaa-custom-bucket-path header in create_bucket
147+
143148
### Update Account
144149

145150
The `account update` command is used to update an existing account with customizable options.
@@ -149,6 +154,7 @@ The `account update` command is used to update an existing account with customiz
149154
noobaa-cli account update --name <account_name> [--new_name][--uid][--gid][--user]
150155
[--new_buckets_path][--access_key][--secret_key][--regenerate][--fs_backend]
151156
[--allow_bucket_creation][--force_md5_etag][--anonymous][--iam_operate_on_root_account][--default_connection]
157+
[--custom_bucket_path_allowed_list]
152158
```
153159
#### Flags -
154160
- `name` (Required)
@@ -216,6 +222,11 @@ noobaa-cli account update --name <account_name> [--new_name][--uid][--gid][--use
216222
- Type: String
217223
- Description: A default account for Kafka external servers. See bucket-notifications.md.
218224

225+
- `custom_bucket_path_allowed_list`
226+
- Type: String
227+
- Description: Specifies an allowed list where this account can create buckets in using
228+
x-noobaa-custom-bucket-path header in create_bucket
229+
219230
### Account Status
220231

221232
The `account status` command is used to print the status of the account.

src/api/account_api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ module.exports = {
308308
supplemental_groups: {
309309
$ref: 'common_api#/definitions/supplemental_groups'
310310
},
311+
custom_bucket_path_allowed_list: { type: 'string' },
311312
}
312313
},
313314
},

src/api/bucket_api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
},
3434
bucket_claim: { $ref: '#/definitions/bucket_claim' },
3535
force_md5_etag: { type: 'boolean' },
36+
custom_bucket_path: { type: 'string' }
3637
}
3738
},
3839
reply: {

src/api/common_api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,14 +1454,16 @@ module.exports = {
14541454
supplemental_groups: {
14551455
$ref: '#/definitions/supplemental_groups'
14561456
},
1457+
custom_bucket_path_allowed_list: { type: 'string' },
14571458
}
14581459
}, {
14591460
type: 'object',
14601461
required: ['distinguished_name', 'new_buckets_path', 'nsfs_only'],
14611462
properties: {
14621463
distinguished_name: { wrapper: SensitiveString },
14631464
new_buckets_path: { type: 'string' },
1464-
nsfs_only: { type: 'boolean' }
1465+
nsfs_only: { type: 'boolean' },
1466+
custom_bucket_path_allowed_list: { type: 'string' },
14651467
}
14661468
}]
14671469
},

src/cmd/manage_nsfs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ async function fetch_account_data(action, user_input) {
503503
uid: user_input.user ? undefined : user_input.uid,
504504
gid: user_input.user ? undefined : user_input.gid,
505505
new_buckets_path: user_input.new_buckets_path,
506-
fs_backend: user_input.fs_backend ? String(user_input.fs_backend) : config.NSFS_NC_STORAGE_BACKEND
506+
fs_backend: user_input.fs_backend ? String(user_input.fs_backend) : config.NSFS_NC_STORAGE_BACKEND,
507+
custom_bucket_path_allowed_list: user_input.custom_bucket_path_allowed_list,
507508
},
508509
default_connection: user_input.default_connection === undefined ? undefined : String(user_input.default_connection)
509510
};
@@ -542,6 +543,8 @@ async function fetch_account_data(action, user_input) {
542543
} else { // string of true or false
543544
data.allow_bucket_creation = user_input.allow_bucket_creation.toLowerCase() === 'true';
544545
}
546+
// custom_bucket_path_allowed_list deletion specified with empty string ''
547+
data.nsfs_account_config.custom_bucket_path_allowed_list = data.nsfs_account_config.custom_bucket_path_allowed_list || undefined;
545548

546549
return data;
547550
}

src/endpoint/s3/ops/s3_put_bucket.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const config = require('../../../../config');
99
async function put_bucket(req, res) {
1010
const lock_enabled = config.WORM_ENABLED ? req.headers['x-amz-bucket-object-lock-enabled'] &&
1111
req.headers['x-amz-bucket-object-lock-enabled'].toUpperCase() === 'TRUE' : undefined;
12-
await req.object_sdk.create_bucket({ name: req.params.bucket, lock_enabled: lock_enabled });
12+
const custom_bucket_path = req.headers[config.NSFS_CUSTOM_BUCKET_PATH_HTTP_HEADER];
13+
await req.object_sdk.create_bucket({ name: req.params.bucket, lock_enabled, custom_bucket_path });
1314
if (config.allow_anonymous_access_in_test && req.headers['x-amz-acl'] === 'public-read') { // For now we will enable only for tests
1415
const policy = {
1516
Version: '2012-10-17',

src/manage_nsfs/manage_nsfs_constants.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const FROM_FILE = 'from_file';
4646
const ANONYMOUS = 'anonymous';
4747

4848
const VALID_OPTIONS_ACCOUNT = {
49-
'add': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'default_connection', FROM_FILE, ...CLI_MUTUAL_OPTIONS]),
50-
'update': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'new_name', 'regenerate', 'default_connection', ...CLI_MUTUAL_OPTIONS]),
49+
'add': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'custom_bucket_path_allowed_list', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'default_connection', FROM_FILE, ...CLI_MUTUAL_OPTIONS]),
50+
'update': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'custom_bucket_path_allowed_list', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'new_name', 'regenerate', 'default_connection', ...CLI_MUTUAL_OPTIONS]),
5151
'delete': new Set(['name', ...CLI_MUTUAL_OPTIONS]),
5252
'list': new Set(['wide', 'show_secrets', 'gid', 'uid', 'user', 'name', 'access_key', ...CLI_MUTUAL_OPTIONS]),
5353
'status': new Set(['name', 'access_key', 'show_secrets', ...CLI_MUTUAL_OPTIONS]),
@@ -123,6 +123,7 @@ const OPTION_TYPE = {
123123
gid: 'number',
124124
supplemental_groups: 'string',
125125
new_buckets_path: 'string',
126+
custom_bucket_path_allowed_list: 'string',
126127
user: 'string',
127128
access_key: 'string',
128129
secret_key: 'string',
@@ -196,6 +197,7 @@ const UNSETTABLE_OPTIONS_OBJ = Object.freeze({
196197
'force_md5_etag': CLI_EMPTY_STRING,
197198
'supplemental_groups': CLI_EMPTY_STRING,
198199
'new_buckets_path': CLI_EMPTY_STRING,
200+
'custom_bucket_path_allowed_list': CLI_EMPTY_STRING,
199201
'ips': CLI_EMPTY_STRING_ARRAY,
200202
});
201203

src/manage_nsfs/manage_nsfs_help_utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Flags:
143143
--force_md5_etag <true | false> (optional) Set the account to force md5 etag calculation. (unset with '') (will override default config.NSFS_NC_STORAGE_BACKEND)
144144
--iam_operate_on_root_account <true | false> (optional) Set the account to create root accounts instead of IAM users in IAM API requests.
145145
--from_file <string> (optional) Use details from the JSON file, there is no need to mention all the properties individually in the CLI
146+
--custom_bucket_path_allowed_list <string> (optional) Set the list of allowed custom bucket paths, separated by colons (:) example: '/gpfs/data/custom1/:/gpfs/data/custom2/'
146147
`;
147148

148149
const ACCOUNT_FLAGS_UPDATE = `
@@ -170,6 +171,7 @@ Flags:
170171
--allow_bucket_creation <true | false> (optional) Update the account to explicitly allow or block bucket creation
171172
--force_md5_etag <true | false> (optional) Update the account to force md5 etag calculation (unset with '') (will override default config.NSFS_NC_STORAGE_BACKEND)
172173
--iam_operate_on_root_account <true | false> (optional) Update the account to create root accounts instead of IAM users in IAM API requests.
174+
--custom_bucket_path_allowed_list <string> (optional) Update the list of allowed custom bucket paths, separated by colons (:) example: '/gpfs/data/custom1/:/gpfs/data/custom2/' (override;unset with '')
173175
`;
174176

175177
const ACCOUNT_FLAGS_DELETE = `

0 commit comments

Comments
 (0)