-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Zeppelin-1561] Improve sync for multiuser environment #1537
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
[Zeppelin-1561] Improve sync for multiuser environment #1537
Conversation
anthonycorbacho
left a comment
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.
Thank you for handeling this case, i added a comment please let me know what your think about it
| } | ||
|
|
||
| private void makePrivate(String noteId, AuthenticationInfo subject) { | ||
| if (subject != null && !"anonymous".equals(subject.getUser())) { |
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.
How about creating in AuthenticationInfo a new method called isAnonymous(AuthenticationInfo subject) and move the check inside?
something like
// In AuthenticationInfo.java
private static final String ANONYMOUS = "anonymous";
public static boolean isAnonymous(AuthenticationInfo subject) {
if (subject != null ) {
LOG.info("Subject is null assuming anonymous");
return true;
}
return ANONYMOUS.equals(subject.getUser();
}
//for the fun
public boolean isAnonymous() {
return ANONYMOUS.equals(user);
}
//then here you can do something like this in makePrivate
if (AuthenticationInfo.isAnonymous(subject)) {
// Add maybe meaningful log :)
return;
}
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
Set<String> users = notebookAuthorization.getOwners(noteId);
users.add(subject.getUser());
notebookAuthorization.setOwners(noteId, users);
users = notebookAuthorization.getReaders(noteId);
users.add(subject.getUser());
notebookAuthorization.setReaders(noteId, users);
users = notebookAuthorization.getWriters(noteId);
users.add(subject.getUser());
notebookAuthorization.setWriters(noteId, users);
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.
makes sense, can be reused to make anonymous consistent in usage over codebase. I'll change now
|
@anthonycorbacho addressed in d0a8c3c with some minor changes |
| LOG.info("No storages could be initialized, using default {} storage", defaultStorage); | ||
| initializeDefaultStorage(conf); | ||
| } | ||
| //syncOnStart(); |
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.
I don't see syncOnStart method called anywhere. So, i believe you commented the above line by mistake.
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.
@rajarajan-g thanks for pointing to it. actually initial purpose was to delete it, but it was extracted into sub-function and commented out. addressed by deleting it in 1c11c2d
| } | ||
| NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance(); | ||
| Set<String> users = notebookAuthorization.getOwners(noteId); | ||
| users.add(subject.getUser()); |
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.
Could you elaborate why 'makePrivate()' routine, which is being used inside of sync() adds current user as a owner, reader, writer?
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.
right, it sets it when pulling notes from secondary storage to your main one
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.
Can you explain why it sets when pulling notes from secondary storage to the main one?
For example, what happen if a note permission has a user as a reader, but not as a writer and owner?
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.
if it's pulling, that means there was no such a note in main storage and it's pulling new note from secondary storage. Thus, that new note not supposed to have previous owners, readers, writers. So generally it's same as creating note and only owner should be set. But I also set readers and writers in order other users don't see that new note (make it private).
|
@Leemoonsoo your comment makes sense if there's already existing acl for the note. addressed it with test under e41b9b9 |
b5d026c to
0355f26
Compare
0355f26 to
b3e6ed3
Compare
|
CI is green, ready for review |
|
LGTM merging if no more discussion |
### What is this PR for? apply multi-tenancy for storage sync mechanism ### What type of PR is it? Bug Fix | Improvement ### Todos * [x] - broadcast on sync * [x] - set permissions for pulled notes * [x] - add test ### What is the Jira issue? [ZEPPELIN-1561](https://issues.apache.org/jira/browse/ZEPPELIN-1561) ### How should this be tested? Outline the steps to test the PR here. ### Screenshots (if appropriate) green CI ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Khalid Huseynov <[email protected]> Closes apache#1537 from khalidhuseynov/improve/sync-multiuser and squashes the following commits: b3e6ed3 [Khalid Huseynov] add userAndRoles 0f2ade7 [Khalid Huseynov] reformat style bd1a44a [Khalid Huseynov] address comment + test 05afa2a [Khalid Huseynov] remove syncOnStart b104249 [Khalid Huseynov] add isAnonymous 1a54cc0 [Khalid Huseynov] set perms for pulling notes - make them private 585a675 [Khalid Huseynov] reload, sync and broadcast on login cd1c3fa [Khalid Huseynov] don't sync on start
### What is this PR for? apply multi-tenancy for storage sync mechanism ### What type of PR is it? Bug Fix | Improvement ### Todos * [x] - broadcast on sync * [x] - set permissions for pulled notes * [x] - add test ### What is the Jira issue? [ZEPPELIN-1561](https://issues.apache.org/jira/browse/ZEPPELIN-1561) ### How should this be tested? Outline the steps to test the PR here. ### Screenshots (if appropriate) green CI ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Khalid Huseynov <[email protected]> Closes apache#1537 from khalidhuseynov/improve/sync-multiuser and squashes the following commits: b3e6ed3 [Khalid Huseynov] add userAndRoles 0f2ade7 [Khalid Huseynov] reformat style bd1a44a [Khalid Huseynov] address comment + test 05afa2a [Khalid Huseynov] remove syncOnStart b104249 [Khalid Huseynov] add isAnonymous 1a54cc0 [Khalid Huseynov] set perms for pulling notes - make them private 585a675 [Khalid Huseynov] reload, sync and broadcast on login cd1c3fa [Khalid Huseynov] don't sync on start
What is this PR for?
apply multi-tenancy for storage sync mechanism
What type of PR is it?
Bug Fix | Improvement
Todos
What is the Jira issue?
ZEPPELIN-1561
How should this be tested?
Outline the steps to test the PR here.
Screenshots (if appropriate)
green CI
Questions: