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

[improve][broker] enhance grant permission module to reduce zk metadata #16792

Closed

Conversation

TakaHiR07
Copy link
Contributor

@TakaHiR07 TakaHiR07 commented Jul 26, 2022

Motivation

related to #16768

Modifications

pulsar old version

partition (e.g., persistent://public/default/mytopic-partition-0) based topic (e.g., persistent://public/default/mytopic)
grant only partition grant all partition and then grant based topic
revoke only partition revoke all partition and then revoke based topic (shutdown if throw exception)
get only partition only based topic
check check partition and then check based topic only based topic

pulsar new version

partition (e.g., persistent://public/default/mytopic-partition-0) based topic (e.g., persistent://public/default/mytopic)
grant based topic only based topic
revoke revoke all partition granted in previous version then revoke based topic revoke all partition granted in previous version then revoke based topic
get get this partition and then get based only based topic
check check partition and then check based topic only based topic

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no
  • The rest endpoints: no
  • The admin cli options: no
  • Anything that affects deployment: no

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@TakaHiR07 TakaHiR07 changed the title Enhance grant permission on topic fix can not revoke permission after update topic partition Aug 3, 2022
@TakaHiR07
Copy link
Contributor Author

@nodece @Technoboy- @codelipenghui PTAL, this problem would result in permission can not be revoked

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 3, 2022
@nodece
Copy link
Member

nodece commented Aug 4, 2022

Hi @TakaHiR07, Thanks for your contribution! I think you should consider the compatibility here.

@TakaHiR07
Copy link
Contributor Author

TakaHiR07 commented Aug 18, 2022

I have changed the proposal and I think it is the better way to solve this problem and meet the compatibility. Please take a look, @nodece @codelipenghui @BewareMyPower

pulsar old version

partition (e.g., persistent://public/default/mytopic-partition-0) based topic (e.g., persistent://public/default/mytopic)
grant only partition grant all partition and then grant based topic
revoke only partition revoke all partition and then revoke based topic (shutdown if throw exception)
get only partition only based topic
check check partition and then check based topic only based topic

pulsar new version

partition (e.g., persistent://public/default/mytopic-partition-0) based topic (e.g., persistent://public/default/mytopic)
grant only partition only based topic
revoke only partition revoke based topic and then revoke partition (it doesn't matter if revoke partition failed)
get only partition only based topic
check check partition and then check based topic only based topic

@TakaHiR07 TakaHiR07 closed this Aug 18, 2022
@TakaHiR07 TakaHiR07 reopened this Aug 18, 2022
@nodece
Copy link
Member

nodece commented Aug 22, 2022

/pulsarbot rerun-failure-checks

@nodece
Copy link
Member

nodece commented Aug 22, 2022

This table looks confused, I think you should follow the #16792, you also need to improve the get action.

@TakaHiR07 TakaHiR07 force-pushed the enhance_grant_permission_on_topic branch from 1ce5cd6 to 0e5003a Compare August 31, 2022 07:37
@nodece nodece requested review from merlimat and Technoboy- October 14, 2022 04:02
Copy link
Member

@michaeljmarshall michaeljmarshall 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 your updates @TakaHiR07. I left some comments, let me know what you think.

@@ -247,7 +247,8 @@ public CompletableFuture<Void> grantPermissionAsync(TopicName topicName, Set<Aut
}
throw new IllegalStateException("policies are in readonly mode");
}
String topicUri = topicName.toString();
// Enhancement: only grant permission on based topic
String topicUri = topicName.getPartitionedTopicName();
Copy link
Member

Choose a reason for hiding this comment

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

I think this might have been a misunderstanding of my review. The optimization is simply that we do not recursively add topic names when granting permission in the PersistentTopicsBase#internalGrantPermissionsOnTopic method. I think it is valid to grant a role permission to produce to a single partition of a partitioned topic, so we shouldn't make this update here.

Copy link
Member

Choose a reason for hiding this comment

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

Good catch! All partitions should have the same permissions, is that right?

Comment on lines -331 to -339
if (numPartitions > 0) {
for (int i = 0; i < numPartitions; i++) {
TopicName topicNamePartition = topicName.getPartition(i);
future = future.thenCompose(unused -> grantPermissionsAsync(topicNamePartition, role,
actions));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This is all that is required for the optimization (regarding my other comment).

@@ -273,6 +273,24 @@ protected CompletableFuture<Map<String, Set<AuthAction>>> internalGetPermissions
}
}
}

// If topic is partitioned, add based topic permission
Copy link
Member

Choose a reason for hiding this comment

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

I do not think we should grant permission based on the partition's base topic. If the call is about a specific permission, we should respond with the result for that partition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaeljmarshall Is your idea the same as I described in #16792 (comment) ?? That's what I thought at the beginning, marked as plan 1.

plan 2 is described in #16792 (comment), this one is designed based on the idea of @nodece .

Both of the two plan can enhance. I think plan 1 would have better compatibility with previous version, while plan 2 would have cleaner permission record.

@congbobo184
Copy link
Contributor

@TakaHiR07 hi, I move this PR to release/2.9.5, if you have any questions, please ping me. thanks.

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

The pr had no activity for 30 days, mark with Stale label.

@poorbarcode
Copy link
Contributor

Since we will start the RC version of 3.0.0 on 2023-04-11, I will change the label/milestone of PR who have not been merged.

  • The PR of type feature is deferred to 3.1.0
  • The PR of type fix is deferred to 3.0.1

So drag this PR to 3.0.1

@michaeljmarshall
Copy link
Member

@TakaHiR07 - I am so sorry for losing track of this PR. Are you interested in continuing your work on it? If not, I am going to pick up the work in a couple weeks. Thank you for your valuable observations and contributions so far!

@TakaHiR07
Copy link
Contributor Author

@TakaHiR07 - I am so sorry for losing track of this PR. Are you interested in continuing your work on it? If not, I am going to pick up the work in a couple weeks. Thank you for your valuable observations and contributions so far!

There is another pr about this work, you can take a look of it. #18222. I am glad to continue improve this work

@Technoboy- Technoboy- modified the milestones: 3.1.0, 3.2.0 Jul 31, 2023
@TakaHiR07 TakaHiR07 closed this Sep 19, 2023
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.