Skip to content

HDDS-10454. Make OzoneAcl immutable#6319

Merged
ChenSammi merged 10 commits intoapache:masterfrom
adoroszlai:HDDS-10454
Mar 13, 2024
Merged

HDDS-10454. Make OzoneAcl immutable#6319
ChenSammi merged 10 commits intoapache:masterfrom
adoroszlai:HDDS-10454

Conversation

@adoroszlai
Copy link
Contributor

@adoroszlai adoroszlai commented Mar 3, 2024

What changes were proposed in this pull request?

Make OzoneAcl immutable. Its aclBitSet is a built-in mutable object, so avoid exposing it. Instead provide methods for read access, as well as copying OzoneAcl with changed bits or scope.

Draft because #6268 would introduce conflicts with this one.

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

How was this patch tested?

Refactoring, covered by existing tests.

https://github.com/adoroszlai/ozone/actions/runs/8129619085

@adoroszlai adoroszlai self-assigned this Mar 3, 2024
@adoroszlai
Copy link
Contributor Author

@ChenSammi @ivandika3 @smengcl @whbing please take a look

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

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

Thanks for the OzoneAcl improvements. I have left some minor comments.

* Default constructor.
*/
public OzoneAcl() {
// TODO use varargs constructor
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be done in this patch? Seems the other constructors already using varargs.

If there are a lot of codes that construct the OzoneAcl this way, perhaps we can defer this to another patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I wanted to defer this to another PR, because there are 70 callers, so it would inflate the patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created HDDS-10515.

* OzoneUtils.addAcl().
* @param acls
* @param parentAcls
* @param scope
Copy link
Contributor

@ivandika3 ivandika3 Mar 4, 2024

Choose a reason for hiding this comment

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

Thanks for the logic simplification. Could you help update the Javadoc for inheritDefaultAcls?

Helper function to inherit default ACL as access ACL for child object

Is outdated since the inherited ACLs can be of DEFAULT scope (for directory ACLs)

}

public boolean checkAccess(ACLType acl) {
return ((aclBitSet.get(acl.ordinal())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's reuse isSet for this

Copy link
Contributor

@ivandika3 ivandika3 Mar 4, 2024

Choose a reason for hiding this comment

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

Also let's add @VisibleForTesting for isSet since it seems to be only used in tests.

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

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

Thank you for updating the patch. LGTM +1.

case USER:
if (a.getName().equals(ugi.getShortUserName())) {
return checkIfAclBitIsSet(aclToCheck, rights);
return a.checkAccess(aclToCheck);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: checkIfAclBitIsSet method can be removed as it not in used now.

@adoroszlai adoroszlai marked this pull request as ready for review March 5, 2024 12:34
@adoroszlai adoroszlai requested a review from smengcl March 5, 2024 17:16
@adoroszlai adoroszlai added the code-cleanup Changes that aim to make code better, without changing functionality. label Mar 5, 2024
@adoroszlai adoroszlai requested review from ChenSammi, aswinshakil, fapifta and whbing and removed request for whbing March 8, 2024 04:19
Copy link
Contributor

@ChenSammi ChenSammi left a comment

Choose a reason for hiding this comment

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

The patch LGTM. Thanks @adoroszlai , and @whbing @ivandika3 for the review.

@ChenSammi ChenSammi merged commit 6cd0b6f into apache:master Mar 13, 2024
@adoroszlai adoroszlai deleted the HDDS-10454 branch March 13, 2024 09:34
@adoroszlai
Copy link
Contributor Author

Thanks @ChenSammi, @ivandika3, @whbing for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-cleanup Changes that aim to make code better, without changing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants