ZEPPELIN-2224. Throw more meaningful exception when kerberos is enabled in livy interpreter#2104
ZEPPELIN-2224. Throw more meaningful exception when kerberos is enabled in livy interpreter#2104zjffdu wants to merge 2 commits intoapache:masterfrom
Conversation
|
@prabhjyotsingh @felixcheung Please help review |
| throw new SessionNotFoundException(cause.getResponseBodyAsString()); | ||
| } | ||
| throw new LivyException(cause.getResponseBodyAsString() + "\n" | ||
| + ExceptionUtils.getFullStackTrace(ExceptionUtils.getRootCause(e))); |
There was a problem hiding this comment.
is this going to bubble up to the face of the user with the whole stack?
perhaps logger.error it instead?
There was a problem hiding this comment.
Yes, this is the default behavior of zeppelin interpreter. See
https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java#L191
There was a problem hiding this comment.
I'm not sure I get it though. Here we are creating a new exception with the full stack trace of the inner/original exception in the exception message itself. In the example you point to setResult(e.getMessage()) would then get the whole message + stack and set that as the result of the paragraph, which would be huge?
There was a problem hiding this comment.
I mean if no error message is speficed explicitly, job stack strace will be used as the error message, see
https://github.com/apache/zeppelin/blob/master/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java#L331
There was a problem hiding this comment.
hmm, ok, why not also include the original exception?
https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html#Exception(java.lang.String,%20java.lang.Throwable)
There was a problem hiding this comment.
The previous implementation use the original exception without the ResponseBody, the purpose of this PR is to add the ResponseBody to exception message, so that in frontend, the error message is more meaningful in kerberos enviroment. See the comparison in PR description.
|
ping @felixcheung |
…ed in livy interpreter
|
Merge if no more comments |
…ed in livy interpreter ### What is this PR for? In kerberos enviroment, user would get the following exception is impersonation configuration is not correctly. This is not so useful for users. This PR would print more meaning exception for users. ``` org.springframework.web.client.HttpClientErrorException: 403 Forbidden at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:620) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecuteSubject(KerberosRestTemplate.java:202) at org.springframework.security.kerberos.client.KerberosRestTemplate.access$100(KerberosRestTemplate.java:67) at org.springframework.security.kerberos.client.KerberosRestTemplate$1.run(KerberosRestTemplate.java:191) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:360) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecute(KerberosRestTemplate.java:187) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:498) at org.apache.zeppelin.livy.BaseLivyInterprereter.callRestAPI(BaseLivyInterprereter.java:406) at org.apache.zeppelin.livy.BaseLivyInterprereter.createSession(BaseLivyInterprereter.java:192) at org.apache.zeppelin.livy.BaseLivyInterprereter.initLivySession(BaseLivyInterprereter.java:98) at org.apache.zeppelin.livy.BaseLivyInterprereter.open(BaseLivyInterprereter.java:80) at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:69) ``` ### What type of PR is it? [Improvement] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-2224 ### How should this be tested? Tested manually in secured cluster. ### Screenshots (if appropriate) Before this PR ``` org.springframework.web.client.HttpClientErrorException: 403 Forbidden at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:620) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecuteSubject(KerberosRestTemplate.java:202) at org.springframework.security.kerberos.client.KerberosRestTemplate.access$100(KerberosRestTemplate.java:67) at org.springframework.security.kerberos.client.KerberosRestTemplate$1.run(KerberosRestTemplate.java:191) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:360) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecute(KerberosRestTemplate.java:187) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:498) at org.apache.zeppelin.livy.BaseLivyInterprereter.callRestAPI(BaseLivyInterprereter.java:406) at org.apache.zeppelin.livy.BaseLivyInterprereter.createSession(BaseLivyInterprereter.java:192) at org.apache.zeppelin.livy.BaseLivyInterprereter.initLivySession(BaseLivyInterprereter.java:98) at org.apache.zeppelin.livy.BaseLivyInterprereter.open(BaseLivyInterprereter.java:80) at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:69) ``` After this PR ``` org.apache.zeppelin.livy.LivyException: {"msg":"User 'zeppelin-sandbox' not allowed to impersonate 'Some(user1)'."} org.springframework.web.client.HttpClientErrorException: 403 Forbidden at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:620) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecuteSubject(KerberosRestTemplate.java:202) at org.springframework.security.kerberos.client.KerberosRestTemplate.access$100(KerberosRestTemplate.java:67) at org.springframework.security.kerberos.client.KerberosRestTemplate$1.run(KerberosRestTemplate.java:191) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:360) at org.springframework.security.kerberos.client.KerberosRestTemplate.doExecute(KerberosRestTemplate.java:187) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:498) at org.apache.zeppelin.livy.BaseLivyInterprereter.callRestAPI(BaseLivyInterprereter.java:407) at org.apache.zeppelin.livy.BaseLivyInterprereter.createSession(BaseLivyInterprereter.java:193) at org.apache.zeppelin.livy.BaseLivyInterprereter.initLivySession(BaseLivyInterprereter.java:99) ``` ### 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 #2104 from zjffdu/ZEPPELIN-2224 and squashes the following commits: 67feb4c [Jeff Zhang] code cleanup 0221193 [Jeff Zhang] ZEPPELIN-2224. Throw more meaningful exception when kerberos is enabled in livy interpreter (cherry picked from commit d5b4698) Signed-off-by: Jeff Zhang <zjffdu@apache.org>
What is this PR for?
In kerberos enviroment, user would get the following exception is impersonation configuration is not correctly. This is not so useful for users. This PR would print more meaning exception for users.
What type of PR is it?
[Improvement]
Todos
What is the Jira issue?
How should this be tested?
Tested manually in secured cluster.
Screenshots (if appropriate)
Before this PR
After this PR
Questions: