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 | Add owner_account to the bucket schema as a required property #7776

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

shirady
Copy link
Contributor

@shirady shirady commented Jan 30, 2024

Explain the changes

  1. Add owner_account to the bucket schema as a required property (it was already added as property in PR NSFS | NC | Allow one or more buckets to use the same dir path #7718.
  2. Add undefined values in _id and owner_account to keep the order the properties when printing the data object, and change the position of creation_date.
  3. Change the function verify_bucket_owner to return the account_id (owner_account is the account id).
  4. Added tests for the schema addition of required value (and adding additional test of _id).
  5. Update test_bucketspace_fs by adding _id to the account (that will be used as owner_account when creating a bucket) and edit one of the test paths to allow it to pass on Mac when running the test locally.

Issues: Fixed #7768

  1. Currently the output of sudo node src/cmd/manage_nsfs bucket status --name <bucke-name> is different if the bucket was created in the manage_nsfs or by s3 command - in the first option we don't have the property owner_account.

Testing Instructions:

Manual test:

  1. Create a bucket with s3
  2. Create a bucket with manage nsfs
  3. compare the details of the created buckets

Unit tests:
For running the unit test with the new tests (or updated tests), please run:

  • sudo npx jest test_nc_nsfs_bucket_cli.test.js

  • npx jest test_nc_nsfs_bucket_schema_validation.test.js

  • sudo node ./node_modules/mocha/bin/mocha src/test/unit_tests/test_bucketspace_fs.js

  • Doc added/updated

  • Tests added

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.

LGTM

Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
@shirady shirady force-pushed the bucket-create-output branch from 3f91707 to 3bb194e Compare January 31, 2024 08:18
@shirady
Copy link
Contributor Author

shirady commented Jan 31, 2024

Manual Testing Instructions:

  1. First, create the FS_ROOT and a directory for a bucket: mkdir -p /tmp/nsfs_root1/my-bucket and give permissions chmod 777 /tmp/nsfs_root1/my-bucket.
    This will be the argument for:
  • new_buckets_path flag /tmp/nsfs_root1 (that we will use in the account commands)
  • path in the buckets commands /tmp/nsfs_root1/my-bucket (that we will use in bucket commands).
  1. Create an account with manage nsfs:
    sudo node src/cmd/manage_nsfs account add --name <account-name> --email <account-email> --new_buckets_path <new-bucket-path> --access-key <access-key> --secret_key <secret-key> --uid <uid number> --gid <gid number>.

  2. Use this alias with AWS CLI (copy the <access-key> and <secret-key>):
    alias s3-nc-user-1='AWS_ACCESS_KEY_ID=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:6443.

  3. Run the server (NC NSFS): sudo node src/cmd/nsfs --debug 3. (debug level would help us with finding relevant logs).
    Notes:

  • We need this step because when we use the AWS CLI we need the server (unlike creating the bucket using manage nsfs).
  • If you change the code then you need to stop the server (ctrl + c) and rerun it.
  1. Create a bucket with AWS CLI.
    s3-nc-user-1 s3 mb s3://<bucket-name-1> or s3-nc-user-1 s3api create-bucket --bucket <bucket name-1>.

  2. Create a bucket with manage nsfs
    sudo node src/cmd/manage_nsfs bucket add --name --email --path .

  3. compare the details of the created buckets by using the manage nsfs bucket status command:
    sudo node src/cmd/manage_nsfs bucket status --name <bucket name-1>
    sudo node src/cmd/manage_nsfs bucket status --name <bucket name-2>

Output for example:
bucket created using manage nsfs

{
  "response": {
    "code": "BucketStatus",
    "reply": {
      "_id": "<id>",
      "name": "bucket-shira-5",
      "owner_account": "<id>",
      "system_owner": "<email>",
      "bucket_owner": "<email>",
      "versioning": "DISABLED",
      "creation_date": "2024-01-31T09:04:30.951Z",
      "path": "/tmp/nsfs_root1/my-bucket",
      "should_create_underlying_storage": false
    }
  }
}

bucket created using AWS CLI

{
  "response": {
    "code": "BucketStatus",
    "reply": {
      "_id": "<id>",
      "name": "user1-bucket-test-5",
      "owner_account": "<id>",
      "system_owner": "<email>",
      "bucket_owner": "<email>",
      "versioning": "DISABLED",
      "creation_date": "2024-01-31T08:40:55.902Z",
      "path": "/tmp/nsfs_root1/user1-bucket-test-5",
      "should_create_underlying_storage": true
    }
  }
}

Note: There is a difference in property should_create_underlying_storage:

  • When the bucket is created using manage nsfs the value is false because we are not creating the directory, we use the existing directory.
  • When the the bucket is created using AWS CLI the value is true when a user creates a bucket we also create a directory with the same name.
    Therefore, you can see the difference in the path property (the same directory as bucket name in AWS CLI create bucket while in manage nsfs it is the path that we passed that doesn't contain the name of the bucket).

@shirady shirady merged commit 2212055 into noobaa:master Jan 31, 2024
10 checks passed
@shirady shirady deleted the bucket-create-output branch January 31, 2024 08:56
@shirady shirady mentioned this pull request Jan 31, 2024
2 tasks
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.

There is difference in <bucketname>.json file , if the user create bucket from node command and aws mb command
2 participants