Skip to content

Conversation

@dombizita
Copy link
Contributor

What changes were proposed in this pull request?

We discovered this problem during the implementation of HttpFS Gateway. With OFS mkdir -p if we wanted to create a bucket in an already existing volume with ACLs enabled and a non-admin user as the owner of the volume, we got a permission denied exception. This could happened, because when we wanted to create a bucket and it didn't exist before we tried to create the volume first. In this case we got the permission denied, because the not admin user couldn't create a volume. But as the volume existed and and the not admin user was the owner of it, this shouldn't happen, the user could have created the bucket.

In this change I modified the getBucket() method in the BasicRootedOzoneClientAdapterImpl class, so it first tries to get the VolumeInfo and the BucketInfo; if it was successful, it returns the BucketInfo. If it wasn't and the createIfNotExist is true it checks if the volume is null.
If the volume in null it tries to get the volume again, to figure out if we have permission or not. If the getVolume threw VOLUME_NOT_FOUND we try to create the volume (we ignore if we got VOLUME_ALREADY_EXISTS exception). If the volume creation was successful we get the VolumeInfo. Else we throw the appropriate exceptions.
If the volume wasn't null in the beginning, it tries to create the bucket (we ignore if we got BUCKET_ALREADY_EXISTS exception) and we return the BucketInfo in the end, else we throw the appropriate exception.

I also removed the proxy variable of the class, as it was only used in the getBucket() method and we can get the bucketDetails via the volume.getBucket().

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-5891

How was this patch tested?

Built the project successfully.

@avijayanhwx avijayanhwx requested a review from smengcl November 8, 2021 17:34
Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for the said case

@dombizita dombizita changed the title HDDS-5891 OFS mkdir -p does not work when volume is pre-created. HDDS-5891 OFS mkdir -p does not work as expected for bucket creation when volume exists due to volume create ACL check. Nov 10, 2021
@dombizita dombizita closed this Nov 10, 2021
@dombizita dombizita deleted the HDDS-5891 branch March 9, 2022 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants