ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob#2925
ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob#2925zjffdu wants to merge 1 commit into
Conversation
|
@felixcheung Mind to help review it ? |
| // paragraph manually. | ||
| p.setAuthenticationInfo(new AuthenticationInfo((p.getUser()))); | ||
| } else { | ||
| p.setAuthenticationInfo(AuthenticationInfo.ANONYMOUS); |
There was a problem hiding this comment.
looks ok, is it better to make sure authenticationInfo is set when scheduling the cronjob?
There was a problem hiding this comment.
I didn't find a more proper place for that :(
Code refactoring is needed for Paragraph/Note for more clean code IMHO
|
LGTM |
|
so running via cron will use the last user that executed a paragraph. that does not fit exactly to the docu change from original PR:
|
|
Thanks @weand , even I didn't realize the user in note.json means the last user run the paragraph (I thought it is the owner). In that case, it seems meaningless to store user in note.json IMHO. |
|
Update the PR to run the cron job as the note owner |
| if (owners.isEmpty()) { | ||
| p.setAuthenticationInfo(AuthenticationInfo.ANONYMOUS); | ||
| } else { | ||
| p.setAuthenticationInfo(new AuthenticationInfo(owners.iterator().next())); |
There was a problem hiding this comment.
should we check if owners.iterator().next() is an empty string?
There was a problem hiding this comment.
Is it possible ? If it's empty string, then it should be a bug in authorization component.
|
Groups can be note owners. As I see How can I find the user which scheduled note? |
|
@mebelousov Currently I would only allow note owner to set the schedule and run cron job via the owner. But seems zeppelin allow multiple owners for one note (it doesn't make sense to me), this is only what I can do the eliminate the security issue. |
|
@zjffdu I have checked with a group as owner. This is ok. |
|
@zjffdu is there a chance to set the cronExecutionUser implictly to the user who activates the cron schedule. |
|
and optionally (or alternatively) introduce a config parameter for a static cronExecutionUser (kind of service user) to be defined by ops team. when this config parameter is set, cron schedules will always use that user. |
|
@mebelousov What do you mean |
|
@mebelousov Your solution depends on shiro setting, we could not assume that in code. |
|
@zjffdu This is your solution ;) I have tested your branch. Do we have uniform opinion that running document as the group is not good? |
|
I am not saying using group is not good, it just depends on user's setting. BTW, it looks like this PR also works for your scenario. In this PR, I would always choose the owner to run the cronjob. And in your case, you just set the owner as group. Do I understand it correctly ? :) |
|
@mebelousov I fully agree that running document as the group is not what a user would expect. That's why I'm proposing another approach again:
|
|
Thanks @weand , I agree with you that your proposal seems much easier. I have updated the PR, please help verify it, thanks |
| if (authenticationInfo != null) { | ||
| p.setAuthenticationInfo(authenticationInfo); | ||
| } | ||
| p.setAuthenticationInfo(authenticationInfo); |
| public synchronized void runAll() { | ||
| runAll(null, true); | ||
| String cronExecutingUser = (String) getConfig().get("cronExecutingUser"); | ||
| if (null == cronExecutingUser) { |
There was a problem hiding this comment.
not sure it is matters here, check for empty or blank string?
|
The notebook now runs successfully after restart with the user who enabled the scheduler. 2 remaining issues:
any chance to fix that case as well? |
|
@weand Thank you! |
|
@weand I don't see the first issue you mentioned, can you confirm that ? |
|
@zjffdu uhm, I can't confirm it. Today after checking out this PR from scratch my first point now works correctly. sorry for the spam. created issue ZEPPELIN-3427 for the second point. is that really so complex to wait for 0.8.1 or 0.9.0 ? Part of that change would be:
|
|
Thanks for the hint @weand , I am not familiar with this component and didn't realize it is so not difficult to do that. PR is updated, please help try that. Thanks again. |
| $scope.note.config.cronExecutingRoles = $rootScope.ticket.roles; | ||
| } | ||
| } else { | ||
| $scope.note.config.cronExecutingUser = ''; |
There was a problem hiding this comment.
Roles should be reset upon disabling cron scheduler, so $scope.note.config.cronExecutingRoles = '' should be added here.
| if (null == cronExecutingUser) { | ||
| cronExecutingUser = "anonymous"; | ||
| } | ||
| AuthenticationInfo authenticationInfo = new AuthenticationInfo(); |
There was a problem hiding this comment.
Parsing roles here with split(...) does not work anymore, when having more than one role.
There were recent changes to parsing the roles, see:
ad77265#diff-4a78303414018c7d08a044687ab6afd4R57
This code instead worked locally. AuthenticationInfo constructor will properly parse the roles:
...
AuthenticationInfo authenticationInfo = new AuthenticationInfo(
cronExecutingUser,
StringUtils.isEmpty(cronExecutingRoles) ? null : cronExecutingRoles,
null);
runAll(authenticationInfo, true);
|
Thanks @weand for review, comments are addressed |
|
great. LGTM 👍 please merge to master and branch-0.8 |
…before cronjob ### What is this PR for? This bug is introduced by #2914, this PR will set authenticationInfo using its user as we will store user into note.json. ### What type of PR is it? [Bug Fix] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-3404 ### How should this be tested? * Manually tested ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjffdu@apache.org> Closes #2925 from zjffdu/ZEPPELIN-3404 and squashes the following commits: b94ecc9 [Jeff Zhang] ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob (cherry picked from commit 1cea92c) Signed-off-by: Jeff Zhang <zjffdu@apache.org>
…before cronjob This bug is introduced by apache#2914, this PR will set authenticationInfo using its user as we will store user into note.json. [Bug Fix] * [ ] - Task * https://issues.apache.org/jira/browse/ZEPPELIN-3404 * Manually tested * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjffdu@apache.org> Closes apache#2925 from zjffdu/ZEPPELIN-3404 and squashes the following commits: b94ecc9 [Jeff Zhang] ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob (cherry picked from commit 1cea92c) Signed-off-by: Jeff Zhang <zjffdu@apache.org> (cherry picked from commit eb7969b) Change-Id: I7c747eaefcc2d7234d0cf07aeaeb26b72c26ee43
…before cronjob ### What is this PR for? This bug is introduced by apache#2914, this PR will set authenticationInfo using its user as we will store user into note.json. ### What type of PR is it? [Bug Fix] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-3404 ### How should this be tested? * Manually tested ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjffdu@apache.org> Closes apache#2925 from zjffdu/ZEPPELIN-3404 and squashes the following commits: b94ecc9 [Jeff Zhang] ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob
…before cronjob ### What is this PR for? This bug is introduced by apache#2914, this PR will set authenticationInfo using its user as we will store user into note.json. ### What type of PR is it? [Bug Fix] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-3404 ### How should this be tested? * Manually tested ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjffdu@apache.org> Closes apache#2925 from zjffdu/ZEPPELIN-3404 and squashes the following commits: b94ecc9 [Jeff Zhang] ZEPPELIN-3404. Fail to run cronjob when user doesn't run it manually before cronjob (cherry picked from commit 1cea92c) Signed-off-by: Jeff Zhang <zjffdu@apache.org>

What is this PR for?
This bug is introduced by #2914, this PR will set authenticationInfo using its user as we will store user into note.json.
What type of PR is it?
[Bug Fix]
Todos
What is the Jira issue?
How should this be tested?
Questions: