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

can not revoke permission after update topic partition #16768

Closed
TakaHiR07 opened this issue Jul 25, 2022 · 3 comments
Closed

can not revoke permission after update topic partition #16768

TakaHiR07 opened this issue Jul 25, 2022 · 3 comments
Assignees
Labels
Stale type/bug The PR fixed a bug or issue reported a bug

Comments

@TakaHiR07
Copy link
Contributor

TakaHiR07 commented Jul 25, 2022

Describe the bug
Steps to reproduce the behavior:

  1. create a 3 partition topic "persistent://test/test/test"
  2. grant produce permission on topic
  3. update topic partition to 5
  4. pulsar-admin topics permissions persistent://test/test/test-partition-5, can not get permission of the new partition, but old partition has the permission
  5. try to produce msg to "persistent://test/test/test", "persistent://test/test/test-partition-0", "persistent://test/test/test-partition-4", all of them succeed
  6. pulsar-admin topics revoke-permission --role xxx persistent://test/test/test, would throw exception:
    "Failed to perform http delete request: javax.ws.rs.ClientErrorException: HTTP 412 Permissions are not set at the topic level"
  7. revoke permission failed and still can produce msg to topic "persistent://test/test/test"

step 1-5 means the updated partition actually has the permission, but the metadata in zk is inconsistent.

When I dive into the code, internalGrantPermissionsOnTopic() would traverse each partition and grant permission. And when do permission checking in PulsarAuthorizationProvider#checkPermission(), it would use partitionedTopicName to judge whether has the permission(proposed in #10333)
企业微信截图_0a8acc9d-beb1-4c98-b8c0-986a8eca8b20
企业微信截图_b5566009-500d-4917-88d0-59a4edff117c

Therefore, it is no need to grant permission for each partition, which not only leads to misleading zk metadata, but also introduces additional operation time overhead.

step 6-7, means we can not revoke the permission after topic update partition, and still can produce msg

The problem is similar, internalRevokePermissionsOnTopic() would firstly traverse each partition and revoke partition permission, and finally revoke partitionedTopic permission. When revoke the permission of "persistent://test/test/test-partition-4", the permission is not existed thus throw exception and skip revoke partitionedTopic permission.

Therefore although revoke partition permission successfully, the partitionedTopic permission also exist, while pr-10333 check permission by partitionedTopicName.

master branch, branch-2.9, branch-2.8 all have the same problem

Expected behavior
no need to grant permission for each partition in internalGrantPermissionsOnTopic()
do not revoke permission for each partition in internalRevokePermissionsOnTopic()
internalGetPermissionsOnTopic() should get the partitionedTopic permission

@TakaHiR07 TakaHiR07 added the type/bug The PR fixed a bug or issue reported a bug label Jul 25, 2022
@TakaHiR07 TakaHiR07 changed the title inconsistent zk metadata of partitioned-topic granted permission can not revoke permission after update topic partition Jul 26, 2022
@github-actions
Copy link

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

@github-actions github-actions bot added the Stale label Aug 26, 2022
@michaeljmarshall
Copy link
Member

6 pulsar-admin topics revoke-permission --role xxx persistent://test/test/test, would throw exception:
"Failed to perform http delete request: javax.ws.rs.ClientErrorException: HTTP 412 Permissions are not set at the topic level"

7 revoke permission failed and still can produce msg to topic "persistent://test/test/test"

In the event that revoking this permission is really important, I think the current workaround would be to grant permission on the "new" partitions, and then revoke permission for the partitioned topic itself.

@github-actions
Copy link

github-actions bot commented Oct 2, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

2 participants