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

Remove deprecated hasDataAccess method. #13574

Merged
merged 6 commits into from
Jul 15, 2024

Conversation

abhioncbr
Copy link
Contributor

@abhioncbr abhioncbr commented Jul 10, 2024

Labels

  • cleanup

Description
In the year 2021, We deprecated the hasDataAccess method of class AccessControl.java ( for reference: PR ). This PR is just removing the deprecated method from the code.

@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 61.98%. Comparing base (59551e4) to head (41114d0).
Report is 750 commits behind head on master.

Files Patch % Lines
...t/controller/api/resources/PinotQueryResource.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #13574      +/-   ##
============================================
+ Coverage     61.75%   61.98%   +0.23%     
+ Complexity      207      198       -9     
============================================
  Files          2436     2555     +119     
  Lines        133233   140614    +7381     
  Branches      20636    21819    +1183     
============================================
+ Hits          82274    87163    +4889     
- Misses        44911    46839    +1928     
- Partials       6048     6612     +564     
Flag Coverage Δ
custom-integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration <0.01% <0.00%> (-0.01%) ⬇️
integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration2 0.00% <0.00%> (ø)
java-11 61.91% <50.00%> (+0.20%) ⬆️
java-21 61.85% <50.00%> (+0.23%) ⬆️
skip-bytebuffers-false 61.95% <50.00%> (+0.21%) ⬆️
skip-bytebuffers-true 61.81% <50.00%> (+34.08%) ⬆️
temurin 61.98% <50.00%> (+0.23%) ⬆️
unittests 61.98% <50.00%> (+0.23%) ⬆️
unittests1 46.44% <ø> (-0.45%) ⬇️
unittests2 27.75% <50.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abhioncbr abhioncbr requested a review from Jackie-Jiang July 10, 2024 18:06
@abhioncbr abhioncbr marked this pull request as ready for review July 10, 2024 18:06
@Jackie-Jiang
Copy link
Contributor

cc @soumitra-st @zhtaoxiang Can you help take a look?

@siddharthteotia
Copy link
Contributor

@vvivekiyer - Can you help review this please

@abhioncbr abhioncbr requested a review from vvivekiyer July 11, 2024 02:06
@@ -24,7 +24,7 @@
public class AllowAllAccessFactory implements AccessControlFactory {
private static final AccessControl ALLOW_ALL_ACCESS = new AccessControl() {
@Override
public boolean hasDataAccess(HttpHeaders httpHeaders, String tableName) {
public boolean hasAccess(String tableName, AccessType accessType, HttpHeaders httpHeaders, String endpointUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can remove this function as the default implementation returns true?

@@ -158,7 +158,7 @@ public Response downloadSegment(
boolean hasDataAccess;
try {
AccessControl accessControl = _accessControlFactory.create();
hasDataAccess = accessControl.hasDataAccess(httpHeaders, tableName);
hasDataAccess = accessControl.hasAccess(tableName, AccessType.READ, httpHeaders, null);
Copy link
Contributor

@vvivekiyer vvivekiyer Jul 12, 2024

Choose a reason for hiding this comment

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

@abhioncbr Can we please pass the endpointUrl Actions.Table.DOWNLOAD_SEGMENT here and in PinotQueryResource (ideally we should pass it in all places where hasAccess is called if not done already). This will allow callers to have different READ restrictions for each endpoint.

Internally at Linkedin, we have different restrictions on READ access for downloadSegment and query endpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll make the required changes. Thanks

Copy link
Contributor

@vvivekiyer vvivekiyer left a comment

Choose a reason for hiding this comment

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

Requested changes to pass endpointUrl when calling hasAccess method.

@@ -292,7 +293,7 @@ private String getQueryResponse(String query, @Nullable SqlNode sqlNode, String

// Validate data access
AccessControl accessControl = _accessControlFactory.create();
if (!accessControl.hasDataAccess(httpHeaders, rawTableName)) {
if (!accessControl.hasAccess(rawTableName, AccessType.READ, httpHeaders, Actions.Table.DOWNLOAD_SEGMENT)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Actions.Table.DOWNLOAD_SEGMENT is not suited for endpointUrl? If endpointUrl is not accessible, we can use null.

Copy link
Contributor Author

@abhioncbr abhioncbr Jul 12, 2024

Choose a reason for hiding this comment

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

@vvivekiyer / @soumitra-st We need some consensus on whether to use Actions.Table.DOWNLOAD_SEGMENT or pass null.

Copy link
Contributor

Choose a reason for hiding this comment

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

@soumitra-st Passing endpointUrl is critical to allow implementations to provide different access restrictions to different read endpoints. Hence I had suggested that we add the relevant action.

All over our codebase (eg: PinotTableResstletResource), we pass the action as endpointUrl. If we feel that a better identifier is needed to identify endpointUrl, we can discuss.

@abhioncbr as this is the query endpoint, the action here should be Actions.Table.QUERY ?

Copy link
Contributor

@soumitra-st soumitra-st Jul 12, 2024

Choose a reason for hiding this comment

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

All over our codebase (eg: PinotTableResstletResource), we pass the action as endpointUrl. If we feel that a better identifier is needed to identify endpointUrl, we can discuss.

@vvivekiyer , if we pass action as endpointUrl across the board, then I am ok with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I will make the change here as suggested by @vvivekiyer and for adding endpointUrl across board, I will raise another PR. Sounds good?

@@ -158,7 +158,7 @@ public Response downloadSegment(
boolean hasDataAccess;
try {
AccessControl accessControl = _accessControlFactory.create();
hasDataAccess = accessControl.hasDataAccess(httpHeaders, tableName);
hasDataAccess = accessControl.hasAccess(tableName, AccessType.READ, httpHeaders, Actions.Table.DOWNLOAD_SEGMENT);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, Actions.Table.DOWNLOAD_SEGMENT action used as endpointUrl. Shall we pass null?

@abhioncbr
Copy link
Contributor Author

Can we merge it?

@vvivekiyer vvivekiyer merged commit 1cc3cef into apache:master Jul 15, 2024
20 checks passed
rajagopr pushed a commit to rajagopr/pinot that referenced this pull request Jul 17, 2024
* Remove deprecated lang3 RandomUtils usage.

* Changes as per the PR comment.

* Remove deprecated method hasDataAccess.

* Changes as per the PR Comments.

* Updated the endpointUrl to QUERY.

* Fix linting issue.
@Nullable String endpointUrl) {
return true;
}
boolean hasAccess(@Nullable String tableName, AccessType accessType, HttpHeaders httpHeaders,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this no longer default true? This is backwards incompatible for users of this interface

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. Adding it back in #14382

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

Successfully merging this pull request may close these issues.

7 participants