Skip to content

Conversation

@arshadmohammad
Copy link
Contributor

Original PR: #338

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Very interesting and useful.

I left a few comments, please take a look


public class ZKUtil {
private static final Logger LOG = LoggerFactory.getLogger(ZKUtil.class);
private static final Map<Integer, String> permCache = new HashMap<Integer, String>();
Copy link
Contributor

Choose a reason for hiding this comment

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

ConcurrentHashMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.


## ZooKeeper Audit Logs

Apache ZooKeeper supports audit logs form version 3.5.7. By default audit logs are disabled. To enable audit logs configure audit.enable=true in conf/zoo.cfg. Audit logs are not logged on all the ZooKeeper servers, but logged only on the servers where client is connected as depicted in below figure.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: form -> from.

I think we should say 3.6.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR I have raised for branch-3.5. After commit I will raise PR for master branch that time I will change this to 3.6.0. Branch releases are independent. I think this way we can be bit more accurate. In last PR was discussed but on second thought this would be the better way.
are you ok with 3.5.7 for branch-5 and 3.6..0 for master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected typo


public String getUserName() {
if (principal == null || principal.isEmpty()) {
return System.getProperty("user.name", "<NA>");
Copy link
Contributor

Choose a reason for hiding this comment

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

You can sample the value as a static variable. You will save an access to the system properties map

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @return string representation of permissions
*/
public static String getPermString(int perms) {
String permString = permCache.get(perms);
Copy link
Contributor

Choose a reason for hiding this comment

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

what about using computeIfAbsent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice

*/
package org.apache.zookeeper.audit;

public class AuditConstants {
Copy link
Contributor

Choose a reason for hiding this comment

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

final

Please also add a private constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

private String getACLs(Request request) {
ByteBuffer reqData = request.request.duplicate();
Copy link
Contributor

Choose a reason for hiding this comment

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

what about 'slice'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, done

String address = null;
String acls = null;
String createMode = null;
ByteBuffer reqData = request.request.duplicate();
Copy link
Contributor

Choose a reason for hiding this comment

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

Slice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
static final ByteBuffer closeConn = ByteBuffer.allocate(0);

private static String loginUser = System.getProperty("user.name", "<NA>");
Copy link
Contributor

Choose a reason for hiding this comment

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

final?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think loginUser can not be marked as final

/**
* Audit log performance reading
*/
public class AuditLogPerfReading {
Copy link
Contributor

Choose a reason for hiding this comment

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

final?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return parentPath + "zNode" + i;
}

public static void main(String[] args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this program really needed? Or is it just a tool you used to profile this new code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This program was just to see the performance impact of audit log. I added here so anybody can run and see the audit log impact on their environment. Also it is added test folder.

Copy link
Contributor

@anmolnar anmolnar left a comment

Choose a reason for hiding this comment

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

@arshadmohammad This is a very useful and long awaited feature. Thanks for working on this.
Without going into the implementation details, I believe it would be better to finalize and submit the code into master and we can talk about backporting to 3.5 after that. We have to ask the community, because 3.5 is already locked down for new features and release process of 3.6 has already been started.

@anmolnar
Copy link
Contributor

anmolnar commented Oct 4, 2019

In terms of the implementation: would you please make the ZKAuditLogger implementation pluggable similarly to zookeeper.clientCnxnSocket. Later we might start to work on Ranger integration and a pluggable audit logger would be very useful.

@anmolnar
Copy link
Contributor

anmolnar commented Oct 8, 2019

@arshadmohammad Fyi. I'm happy to take this over and continue working on it, if you don't have cycles for that. Please let me know.

@arshadmohammad
Copy link
Contributor Author

arshadmohammad commented Oct 11, 2019

... because 3.5 is already locked down for new features and release process of 3.6 has already been started.

I think it is locked for backward incompatible features, not for all features and this feature is not backward incompatible.

@arshadmohammad
Copy link
Contributor Author

In terms of the implementation: would you please make the ZKAuditLogger implementation pluggable similarly to zookeeper.clientCnxnSocket. Later we might start to work on Ranger integration and a pluggable audit logger would be very useful.

Sure, I will make it configurable.

@anmolnar
Copy link
Contributor

anmolnar commented Nov 3, 2019

@arshadmohammad PR hasn't been updated for 24 days. How are you getting on?
I'm still happy to take this over and move forward.

@arshadmohammad
Copy link
Contributor Author

@anmolnar, I will update the patch soon, hopefully by tomorrow. Will try to wind up this work by this weekend

@arshadmohammad
Copy link
Contributor Author

Addressed all the comments and created PR for master branch.
#1133

@arshadmohammad
Copy link
Contributor Author

Feature is merged in PR #1133

@arshadmohammad arshadmohammad deleted the ZOOKEEPER-1260-AuditLog branch December 25, 2019 18:37
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