-
Notifications
You must be signed in to change notification settings - Fork 76
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
NC | NSFS | Schema validation #7544
Conversation
0573001
to
c4e8d79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Added a couple of comments and questions.
c4e8d79
to
abd5b2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@naveenpaul1, please check if the validation that that we have a value (without checking something about the value) is enough to meet the requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also use the schema validation in bucketspace_fs on create bucket :)
abd5b2e
to
1acf2ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naveenpaul1
few comments/questions:
- Am I correct and the creation and read of the account/bucket are not calling any RPC?
- please change the names of those Schema, to reflect that those are standalone (or any other name) schemas and not a RPC ones. Also, we already have files with those names so it can get us confused.
add5c72
to
9144dfb
Compare
Signed-off-by: naveenpaul1 <napaul@redhat.com>
9144dfb
to
626996e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -317,7 +317,7 @@ async function main(argv = minimist(process.argv.slice(2))) { | |||
} | |||
}); | |||
if (await endpoint.is_http_allowed(nsfs_config_root)) { | |||
dbg.log0('nsfs: listening on', util.inspect(`http://localhost:${http_port}`)); | |||
console.log('nsfs: listening on', util.inspect(`http://localhost:${http_port}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, why are we using console and not dbg?
by requiring the console we "hijack" the console, but the console does not have levels like 0,1 ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liranmauda ya totally agree with you, we need to have a discussion on this. In this PR I just reverted the previous code that I accidentally updated in my last PR.
1. Move the NC NSFS schema validation that we had in file `src/sdk/bucketspace_fs.js` (from PR noobaa#7544) to a separate file (`src/manage_nsfs/nsfs_schema_utils.js`) to reuse it. 2. Edit the values of `s3_policy` and `fs_backend` to be undefined (and not empty `''`, as it passed as an argument). 3. Validate the data using schema and return an error in case it doesn't match (details would be passed according to the original message), using a mapping `ManageCLIError.RPC_ERROR_TO_MANAGE`. 4. Update the unit tests for the cases of `s3_policy` and `fs_backend` deletions (separate the argument that we pass as `''` to the actual property that would be `undefined`). 5. Change the `uid` and `gid` extract in function `fetch_account_data` to be `undefined` when the argument user was passed (and not `false`). 6. Use `schema_utils.strictify` with option `additionalProperties: false` in the `nsfs_account_schema` and `nsfs_bucket_schema`. 7. Add the `versioning` definition to the bucket schema. 8. Add tests for the schema validation of nsfs_account_schema and nsfs_bucket_schema. Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1. Move the NC NSFS schema validation that we had in file `src/sdk/bucketspace_fs.js` (from PR noobaa#7544) to a separate file (`src/manage_nsfs/nsfs_schema_utils.js`) to reuse it. 2. Edit the values of `s3_policy` and `fs_backend` to be undefined (and not empty `''`, as it passed as an argument). 3. Validate the data using schema and return an error in case it doesn't match (details would be passed according to the original message), using a mapping `ManageCLIError.RPC_ERROR_TO_MANAGE`. 4. Update the unit tests for the cases of `s3_policy` and `fs_backend` deletions (separate the argument that we pass as `''` to the actual property that would be `undefined`). 5. Change the `uid` and `gid` extract in function `fetch_account_data` to be `undefined` when the argument user was passed (and not `false`). 6. Use `schema_utils.strictify` with option `additionalProperties: false` in the `nsfs_account_schema` and `nsfs_bucket_schema`. 7. Add the `versioning` enum to the bucket schema. 8. Add tests for the schema validation of nsfs_account_schema and nsfs_bucket_schema. Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1. Move the NC NSFS schema validation that we had in file `src/sdk/bucketspace_fs.js` (from PR noobaa#7544) to a separate file (`src/manage_nsfs/nsfs_schema_utils.js`) to reuse it. 2. Edit the values of `s3_policy` and `fs_backend` to be undefined (and not empty `''`, as it passed as an argument). 3. Validate the data using schema and return an error in case it doesn't match (details would be passed according to the original message), using a mapping `ManageCLIError.RPC_ERROR_TO_MANAGE`. 4. Update the unit tests for the cases of `s3_policy` and `fs_backend` deletions (separate the argument that we pass as `''` to the actual property that would be `undefined`). 5. Change the `uid` and `gid` extract in function `fetch_account_data` to be `undefined` when the argument user was passed (and not `false`). 6. Use `schema_utils.strictify` with option `additionalProperties: false` in the `nsfs_account_schema` and `nsfs_bucket_schema`. 7. Add the `versioning` enum to the bucket schema. 8. Add tests for the schema validation of nsfs_account_schema and nsfs_bucket_schema. Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1. Move the NC NSFS schema validation that we had in file `src/sdk/bucketspace_fs.js` (from PR noobaa#7544) to a separate file (`src/manage_nsfs/nsfs_schema_utils.js`) to reuse it. 2. Edit the values of `s3_policy` and `fs_backend` to be undefined (and not empty `''`, as it passed as an argument). 3. Validate the data using schema and return an error in case it doesn't match (details would be passed according to the original message), using a mapping `ManageCLIError.RPC_ERROR_TO_MANAGE`. 4. Update the unit tests for the cases of `s3_policy` and `fs_backend` deletions (separate the argument that we pass as `''` to the actual property that would be `undefined`). 5. Change the `uid` and `gid` extract in function `fetch_account_data` to be `undefined` when the argument user was passed (and not `false`). 6. Use `schema_utils.strictify` with option `additionalProperties: false` in the `nsfs_account_schema` and `nsfs_bucket_schema`. 7. Add the `versioning` enum to the bucket schema. 8. Add tests for the schema validation of nsfs_account_schema and nsfs_bucket_schema. Signed-off-by: shirady <57721533+shirady@users.noreply.github.com> (cherry picked from commit 4d11e6b) Signed-off-by: Nimrod Becker <bnimrod@gmail.com>
Explain the changes
Issues: Fixed #xxx / Gap #xxx
Testing Instructions: