Skip to content

KAFKA-9386; Apply delete ACL filters to resources from filter even if not in cache#7911

Merged
rajinisivaram merged 1 commit intoapache:trunkfrom
rajinisivaram:KAFKA-9386-authorizer-test
Jan 9, 2020
Merged

KAFKA-9386; Apply delete ACL filters to resources from filter even if not in cache#7911
rajinisivaram merged 1 commit intoapache:trunkfrom
rajinisivaram:KAFKA-9386-authorizer-test

Conversation

@rajinisivaram
Copy link
Copy Markdown
Contributor

With the old SimpleAclAuthorizer, we were handling delete filters that matched a single resource by looking up that resource directly, even if it wasn't in the cache. AclAuthorizerTest.testHighConcurrencyDeletionOfResourceAcls relies on this behaviour and fails intermittently when the cache is not up-to-date. This PR includes the resource from non-matching filters even if it is not in the cache to retain the old behaviour.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@rajinisivaram rajinisivaram requested a review from omkreddy January 8, 2020 18:46
@rajinisivaram
Copy link
Copy Markdown
Contributor Author

retest this please

Copy link
Copy Markdown
Contributor

@omkreddy omkreddy left a comment

Choose a reason for hiding this comment

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

@rajinisivaram Thanks for the PR. LGTM.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 9, 2020

@rajinisivaram We look for the resource directly by querying ZK?

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@ijuma When deleting ACLs, we always use the latest ACLs from ZK since the updates use the version. But in order to look up those ACLs, we need to know which resources to look up. For ACL filters that specify a resource pattern (e.g testTopicA or prefixed topic test), we can directly look up that resource to ensure that we get the latest value in ZK. And we were doing that in SimpleAclAuthorizer. For ACL filters that match multiple resources, we match against the resources in aclCache since we dont want to look up all resources in ZK to perform the match. This PR does the same for AclAuthorizer.

If you do Admin.createAcls() followed by Admin.deleteAcls(), if you specify the ACL in both cases, you are guaranteed to delete the ACL regardless of which broker handles the request. If you use a matching filter that doesn't specify the resource pattern for deleteAcls, then we don't provide that guarantee. If we did want to provide that guarantee, we would need to read all resources from ZK for this case.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 9, 2020

Thanks for the explanation. Two comments:

  1. Have we documented this anywhere? It's a bit subtle, so it would be good to do so, if we have not.
  2. Could we write a deterministic test for this behavior (maybe using mocks) so that we don't regress? It can be done as a separate PR.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@ijuma Opened https://issues.apache.org/jira/browse/KAFKA-9392 to document the limitation and add a deterministic test.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 9, 2020

Thanks. We should also check that we can continue to offer this guarantee after KIP-500.

val resourcesToUpdate = aclCache.keys.map { resource =>
// Find all potentially matching resource patterns from the provided filters and ACL cache and apply the filters
val resources = aclCache.keys ++ filters.map(_._1.patternFilter).filter(_.matchesAtMostOne).flatMap(filterToResources)
val resourcesToUpdate = resources.map { resource =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another thing to consider for a separate PR: this method seems highly inefficient. We take all the keys in the cache and do a bunch of transformations. It seems like we should avoid that, no? Intuitively, we would do a filter operation first and then transform only the cache items that match.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will do https://issues.apache.org/jira/browse/KAFKA-8847 first to remove references to the old classes and deprecate those. And that would avoid a lot of the unnecessary conversions. I can see if more can be done to improve this in the same PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@ijuma I guess we don't know yet the exact format in which ACLs will be stored for KIP-500. But I think this guarantee is similar to supporting concurrent updates which we need to do anyway. A deterministic test will at least ensure we will notice if it doesn't work.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@omkreddy @ijuma Thanks for the reviews, merging to trunk. Will address remaining comments under KAFKA-9392 and KAFKA-8847.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants