-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-7007: All ACL changes should use single /kafka-acl-changes path #5161
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
16f5597
KAFKA-7007: All ACL changes should use single /kafka-acl-changes path
big-andy-coates 259df49
Merge branch 'trunk' into single_acl_change_path
big-andy-coates 6013925
Removed unused from ZkData
big-andy-coates b29bd45
Merge branch 'trunk' into single_acl_change_path
big-andy-coates 237db81
Post merge fix up
big-andy-coates 9185513
Jun's requested changes
big-andy-coates 5769d56
Revert back from JSON ACL change event to String based, with either 2…
big-andy-coates 7046b0c
Jun's change requests
big-andy-coates b919bd1
Switch to a hybrid:
big-andy-coates 3280303
Remove todo
big-andy-coates ae50f4e
Split ZkAclChangeStore from ZkAclStore, so that we can have two ZkAcl…
big-andy-coates 23bb972
Jun's requested changes.
big-andy-coates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -941,14 +941,15 @@ class KafkaZkClient private (zooKeeperClient: ZooKeeperClient, isSecure: Boolean | |
| //Acl management methods | ||
|
|
||
| /** | ||
| * Creates the required zk nodes for Acl storage | ||
| * Creates the required zk nodes for Acl storage and Acl change storage. | ||
| */ | ||
| def createAclPaths(): Unit = { | ||
| ZkAclStore.stores.foreach(store => { | ||
| createRecursive(store.aclPath, throwIfPathExists = false) | ||
| createRecursive(store.aclChangePath, throwIfPathExists = false) | ||
| ResourceType.values.foreach(resourceType => createRecursive(store.path(resourceType), throwIfPathExists = false)) | ||
| }) | ||
|
|
||
| ZkAclChangeStore.stores.foreach(store => createRecursive(store.aclChangePath, throwIfPathExists = false)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment of the method should be adjusted to "Creates the required zk nodes for Acl storage and Acl change storage".
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1005,13 +1006,12 @@ class KafkaZkClient private (zooKeeperClient: ZooKeeperClient, isSecure: Boolean | |
| } | ||
|
|
||
| /** | ||
| * Creates Acl change notification message | ||
| * @param resource resource name | ||
| * Creates an Acl change notification message. | ||
| * @param resource resource pattern that has changed | ||
| */ | ||
| def createAclChangeNotification(resource: Resource): Unit = { | ||
| val store = ZkAclStore(resource.nameType) | ||
| val path = store.changeSequenceZNode.createPath | ||
| val createRequest = CreateRequest(path, AclChangeNotificationSequenceZNode.encode(resource), acls(path), CreateMode.PERSISTENT_SEQUENTIAL) | ||
| val aclChange = ZkAclStore(resource.nameType).changeStore.createChangeNode(resource) | ||
| val createRequest = CreateRequest(aclChange.path, aclChange.bytes, acls(aclChange.path), CreateMode.PERSISTENT_SEQUENTIAL) | ||
| val createResponse = retryRequestUntilConnected(createRequest) | ||
| createResponse.maybeThrow | ||
| } | ||
|
|
@@ -1034,24 +1034,25 @@ class KafkaZkClient private (zooKeeperClient: ZooKeeperClient, isSecure: Boolean | |
| * @throws KeeperException if there is an error while deleting Acl change notifications | ||
| */ | ||
| def deleteAclChangeNotifications(): Unit = { | ||
| ZkAclStore.stores.foreach(store => { | ||
| ZkAclChangeStore.stores.foreach(store => { | ||
| val getChildrenResponse = retryRequestUntilConnected(GetChildrenRequest(store.aclChangePath)) | ||
| if (getChildrenResponse.resultCode == Code.OK) { | ||
| deleteAclChangeNotifications(store, getChildrenResponse.children) | ||
| deleteAclChangeNotifications(store.aclChangePath, getChildrenResponse.children) | ||
| } else if (getChildrenResponse.resultCode != Code.NONODE) { | ||
| getChildrenResponse.maybeThrow | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Deletes the Acl change notifications associated with the given sequence nodes | ||
| * @param sequenceNodes | ||
| */ | ||
| private def deleteAclChangeNotifications(store: ZkAclStore, sequenceNodes: Seq[String]): Unit = { | ||
| val aclChangeNotificationSequenceZNode = store.changeSequenceZNode | ||
| * Deletes the Acl change notifications associated with the given sequence nodes | ||
| * | ||
| * @param aclChangePath the root path | ||
| * @param sequenceNodes the name of the node to delete. | ||
| */ | ||
| private def deleteAclChangeNotifications(aclChangePath: String, sequenceNodes: Seq[String]): Unit = { | ||
| val deleteRequests = sequenceNodes.map { sequenceNode => | ||
| DeleteRequest(aclChangeNotificationSequenceZNode.deletePath(sequenceNode), ZkVersion.NoVersion) | ||
| DeleteRequest(s"$aclChangePath/$sequenceNode", ZkVersion.NoVersion) | ||
| } | ||
|
|
||
| val deleteResponses = retryRequestsUntilConnected(deleteRequests) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is called by LiteralAclChangeStore.decode(), which should only decode a 2-part name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot. I've changed LiteralAclChangeStore.decode() to have its own impl. (Basically the old contents of Resource.fromString), to maintain v1.1 behaviour