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

NC | NSFS | Schema validation #7544

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Conversation

naveenpaul1
Copy link
Contributor

@naveenpaul1 naveenpaul1 commented Oct 25, 2023

Explain the changes

  1. Buckets and accounts schema validation
  2. creation_date added to bucket management CLI

Issues: Fixed #xxx / Gap #xxx

  1. https://issues.redhat.com/browse/MCGI-204

Testing Instructions:

  1. Test with invalid schema JSON for bucket and accounts, Should throw an error
  2. Try to create bucket with an invalid creation date, if the creation date missing current data use
  • Doc added/updated
  • Tests added

Copy link
Contributor

@shirady shirady left a 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.

src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
Copy link
Contributor

@shirady shirady left a 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.

src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/sdk/bucketspace_fs.js Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
Copy link
Contributor

@romayalon romayalon left a 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 :)

src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
Copy link
Contributor

@liranmauda liranmauda left a 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:

  1. Am I correct and the creation and read of the account/bucket are not calling any RPC?
  2. 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.

@naveenpaul1 naveenpaul1 force-pushed the nsfs_validation branch 4 times, most recently from add5c72 to 9144dfb Compare October 30, 2023 13:21
Signed-off-by: naveenpaul1 <napaul@redhat.com>
Copy link
Contributor

@liranmauda liranmauda left a 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}`));
Copy link
Contributor

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 ...

Copy link
Contributor Author

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.

@naveenpaul1 naveenpaul1 merged commit 5a62046 into noobaa:master Oct 31, 2023
8 checks passed
@naveenpaul1 naveenpaul1 deleted the nsfs_validation branch December 29, 2023 04:47
shirady added a commit to shirady/noobaa-core that referenced this pull request Jan 9, 2024
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>
shirady added a commit to shirady/noobaa-core that referenced this pull request Jan 9, 2024
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>
shirady added a commit to shirady/noobaa-core that referenced this pull request Jan 10, 2024
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>
nimrod-becker pushed a commit to nimrod-becker/noobaa-core that referenced this pull request Jan 11, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants