noobaa / noobaa-core

High-performance S3 application gateway to any backend - file / s3-compatible / multi-clouds / caching / replication ...
https://www.noobaa.io
Apache License 2.0
265 stars 78 forks source link

NSFS | Bucket is not listing when the bucket --path missing backslash(/) at the beginning of path #8225

Closed naveenpaul1 closed 1 week ago

naveenpaul1 commented 1 month ago

Environment info

Actual behavior

  1. User is able to create a bucket without backslash prefix

node /usr/local/noobaa-core/src/cmd/manage_nsfs.js bucket add --name bucket-test-folder-2 --owner acc_symlink-uid --path tmp/bucket-space-1 { "response": { "code": "BucketCreated", "reply": { "_id": "669f3cc1f41da14306a8c289", "name": "bucket-test-folder-2", "owner_account": "667264f6bd0315122ce9efeb", "system_owner": "acc_symlink-uid", "bucket_owner": "acc_symlink-uid", "versioning": "DISABLED", "creation_date": "2024-07-23T05:16:49.811Z", "path": "tmp/bucket-space-1", "should_create_underlying_storage": false } } }

But when try to list the bucket using s3 ls command bucket is not listing

s3 ls 2024-06-19 04:57:26 bucket-test-folder 2024-07-18 11:47:35 bucket-test-folder-1

bucket-test-folder-2 is missing

After adding backslash

root@4c8c451cfb17 /]# s3 ls 2024-06-19 04:57:26 bucket-test-folder 2024-07-18 11:47:35 bucket-test-folder-1 2024-07-23 05:16:49 bucket-test-folder-2

Expected behavior

  1. bucket-test-folder-2 should list when customer list buckets

Steps to reproduce

  1. create bucket with --path missing starting backslash

    node /usr/local/noobaa-core/src/cmd/manage_nsfs.js bucket add --name bucket-test-folder-2 --owner acc_symlink-uid --path tmp/bucket-space-1

  2. list buckets using s3 ls command.

    More information - Screenshots / Logs / Other output

    NAPI code checking the di location and not able to access dir because of missing /

Logs:

Jul 23 05:26:02 4c8c451cfb17 node[480]: 2024-07-23 05:26:02.850291 [PID-480/TID-523] [L1] FS::FSWorker::Execute: CheckAccess _path=tmp/bucket-space-1 _uid=0 _gid=0 _backend= Jul 23 05:26:02 4c8c451cfb17 node[480]: 2024-07-23 05:26:02.850299 [PID-480/TID-523] [L1] FS::FSWorker::Execute: CheckAccess _path=tmp/bucket-space-1 _uid=0 _gid=0 geteuid()=0 getegid()=0 getuid()=0 getgid()=0 Jul 23 05:26:02 4c8c451cfb17 node[480]: 2024-07-23 05:26:02.850305 [PID-480/TID-480] [L1] FS::FSWorker::OnOK: undefined CheckAccess _path=/tmp/bucket-space-1 Jul 23 05:26:02 4c8c451cfb17 node[480]: 2024-07-23 05:26:02.850310 [PID-480/TID-523] [L1] FS::FSWorker::Execute: CheckAccess _path=tmp/bucket-space-1 took: 0.006813 ms Jul 23 05:26:02 4c8c451cfb17 node[480]: 2024-07-23 05:26:02.850348 [PID-480/TID-480] [L1] FS::FSWorker::OnError: CheckAccess _path=tmp/bucket-space-1 error.Message()=No such file or directory Jul 23 05:26:02 4c8c451cfb17 node[480]: Jul-23 5:26:02.850 [nsfs/480] [L0] core.sdk.bucketspace_fs:: _has_access_to_nsfs_dir: failed [Error: No such file or directory] { code: 'ENOENT', context: 'CheckAccess _path=tmp/bucket-space-1 ' } Jul 23 05:26:02 4c8c451cfb17 node[480]: Jul-23 5:26:02.850 [nsfs/480] [L1] core.sdk.bucketspace_fs:: bucketspace_fs.validate_fs_bucket_access: bucket-test-folder-2 true false

romayalon commented 1 month ago

@naveenpaul1 I don't think this is a bug, please correct me if I miss-understood. We expect absolute paths, therefore, you should specify the '/' at the beginning of the path expressing the root directory.

romayalon commented 2 weeks ago

@naveenpaul1 can I close this one?

naveenpaul1 commented 1 week ago

@romayalon if / expected at the beginning of the path then we should add this validation while creating the bucket, This will avoid missing created bucket while listing. I dont think its a good behaviour where we allow the bucket creation with invalid path and bucket listing is failing for those buckets. WDYT?

romayalon commented 1 week ago

@naveenpaul1 yep I agree, we can add a validation for absolute paths on path and new_buckets_path, but we already have a bug opened for that - https://github.com/noobaa/noobaa-core/issues/8177. let's move this discussion there so we can decide on what we should restrict, like relative paths, config dir path etc

naveenpaul1 commented 1 week ago

@romayalon Then I think we can close this issue and continue with 8177