TEZ-4739: Improve ACLManager - #524
Conversation
| return; | ||
| } | ||
| if (aclInfo == null) { | ||
| return; |
There was a problem hiding this comment.
nit:
if (!aclsEnabled || aclInfo == null) {
return;
}
This comment was marked as outdated.
This comment was marked as outdated.
|
🎊 +1 overall
This message was automatically generated. |
| this.users = new HashMap<>(amACLManager.users); | ||
| this.groups = new HashMap<>(amACLManager.groups); |
There was a problem hiding this comment.
I think this is a Shallow Copy not a Deep Copy? Is it intentional? Though we are doing put here below. But if someone does in future .get(key).add(...) it might lead to some problems, can you check once
something like in future this.users.get(ACLType.AM_VIEW_ACL).add("new_user") inside this class, it will silently modify the global Application Master's ACLs. They might think they are only granting a user access to a specific DAG, but because of the shallow copy, they would accidentally be granting that user global AM access.
The per-DAG ACLManager constructor previously did new HashMap<>(amACLManager.users) and new HashMap<>(amACLManager.groups), which is a shallow copy: the outer map is new, but each Set<String> value is still shared with the AM manager. Today only put(...) is used on those maps, so no leak occurs in practice — but any future this.users.get(ACLType.AM_VIEW_ACL).add(user) inside this class would silently mutate the AM's global ACLs and every sibling DAG's view of them. Deep-copy each inner Set on construction, and add a reflection-based regression test that mutates the DAG manager's set in place and asserts the AM manager is untouched — verified to fail against the shallow-copy version.
|
🎊 +1 overall
This message was automatically generated. |
ayushtkn
left a comment
There was a problem hiding this comment.
Thanx @abstractdog for the fix, Sorry for the delay got pulled into other stuff and this kept on slipping
Changes LGTM
No description provided.