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

NSFS | NC | Changes in nsfs_config_schema Related to strictify #7889

Merged
merged 1 commit into from
May 20, 2024

Conversation

shirady
Copy link
Contributor

@shirady shirady commented Mar 12, 2024

Explain the changes

  1. Add strictify on nsfs_config_schema.
  2. Change the structure of the schema nsfs_config_schema:
    • Replace the description with doc.
    • Remove default.
    • In NSFS_WHITELIST which is type array add items under it.
    • Remove the definitions in nsfs_config_schema and set the additionalProperties to nsfs_node_config_schema.
  3. Edit the printings in load_nsfs_nc_config.

Issues: Fixed #7874

  1. Those changes are originally from after setting strictify on nsfs_config_schema and handling the errors.

GAPS:

  1. GAP - I think we should add validations to some of the properties, for example: NSFS_WHITELIST is validated when the user passes the command sudo node src/cmd/manage_nsfs whitelist --ips <list-og-ips> using verify_whitelist_ips:
    function verify_whitelist_ips(ips_to_validate) {
    for (const ip_to_validate of ips_to_validate) {
    if (net.isIP(ip_to_validate) === 0) {
    const detail_msg = `IP address list has an invalid IP address ${ip_to_validate}`;
    throw_cli_error(ManageCLIError.InvalidWhiteListIPFormat, detail_msg);
    }
    }
    }
  2. GAP (suggestion) - We can translate our recommendations in the schema, for example: ports values 1-65535 using a definition that we have:
    port: {
    type: 'integer',
    minimum: 0,
    maximum: 65535
    },

    In other cases, for example ENDPOINT_FORKS to be minimum 0 and maximum 64 and remove the suggestions from the doc part.

Testing Instructions:

Unit Tests

  1. Run the schema unit tests: npx jest test_nc_nsfs_config_schema_validation.test.js

Manual Tests

To see that the config is used when running the nsfs server.

  1. Check your hostname, run: hostname in your terminal (this will be the <hostname-output> in the next step).
  2. Add a config file: sudo vi /etc/noobaa.conf.d/config.json In this example we added 2 opposite values of ALLOW_HTTP
 {
     "ALLOW_HTTP": false,
     "host_customization": {
         "<hostname-output>": {
             "ALLOW_HTTP": true
         }
     }
 }
  1. Start the server: sudo node src/cmd/nsfs --debug 5
  2. Notice the printings (my-mac is an example of a hostname):
nsfs: config_dir_path=/etc/noobaa.conf.d
nsfs: config.json= {
  ALLOW_HTTP: false,
  host_customization: { 'my-mac': { ALLOW_HTTP: true } }
}
nsfs: merged config.json= { ALLOW_HTTP: true }
[nsfs/75607]    [L0] core.endpoint.endpoint:: Starting S3 HTTP 6001
[nsfs/75607]    [L0] core.endpoint.endpoint:: Started S3 HTTP successfully
  • Doc added/updated
  • Tests added

@shirady shirady self-assigned this Mar 12, 2024
@shirady shirady force-pushed the nsfs-nc-config-schema branch 2 times, most recently from 16d764d to 3870676 Compare March 17, 2024 14:25
@guymguym guymguym modified the milestones: 5.15.4, 5.16.0 Apr 22, 2024
@pull-request-size pull-request-size bot added size/M and removed size/L labels May 16, 2024
1. Add strictify on nsfs_config_schema.
2. Change the structure of the schema nsfs_config_schema:
3. Edit the printings in load_nsfs_nc_config.

Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
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.

Awesome!
Please open a single issue for the suggested extra validations :)

@shirady shirady merged commit f038492 into noobaa:master May 20, 2024
10 checks passed
@shirady shirady deleted the nsfs-nc-config-schema branch May 20, 2024 12:52
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.

NSFS | NC | Schema Changes (Mainly in nsfs_config_schema)
3 participants