This is an automated email from the ASF dual-hosted git repository. zjffdu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push: new 7c6cc03 [ZEPPELIN-4607]. Return OK when fail to run paragraph 7c6cc03 is described below commit 7c6cc039745eafdcdac382428423e0c7dcb2f4ce Author: Jeff Zhang <zjf...@apache.org> AuthorDate: Wed Feb 12 11:08:54 2020 +0800 [ZEPPELIN-4607]. Return OK when fail to run paragraph ### What is this PR for? This PR will return FAIL when fail to run paragraph. And it will contain the the failed paragraph result. ### What type of PR is it? [Improvement] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-4607 ### How should this be tested? * CI pass ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjf...@apache.org> Closes #3642 from zjffdu/ZEPPELIN-4607 and squashes the following commits: f684b5c9f [Jeff Zhang] [ZEPPELIN-4607]. Return OK when fail to run paragraph --- .../main/java/org/apache/zeppelin/rest/NotebookRestApi.java | 3 +-- .../java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java | 10 +++++----- .../src/main/java/org/apache/zeppelin/notebook/Note.java | 5 +++-- .../java/org/apache/zeppelin/notebook/scheduler/CronJob.java | 6 +++++- .../test/java/org/apache/zeppelin/notebook/NotebookTest.java | 12 +++++------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java index 49409bc..d0d7cb3 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java @@ -672,8 +672,7 @@ public class NotebookRestApi extends AbstractRestApi { note.runAll(subject, blocking); } catch (Exception ex) { LOG.error("Exception from run", ex); - return new JsonResponse<>(Status.PRECONDITION_FAILED, - ex.getMessage() + "- Not selected or Invalid Interpreter bind").build(); + return new JsonResponse<>(Status.EXPECTATION_FAILED, ex.getMessage()).build(); } return new JsonResponse<>(Status.OK).build(); } diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java index bb16b94..abb684c 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java @@ -428,7 +428,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testNoteJobs() throws IOException, InterruptedException { + public void testNoteJobs() throws Exception { LOG.info("testNoteJobs"); Note note = null; @@ -489,7 +489,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testGetNoteJob() throws IOException, InterruptedException { + public void testGetNoteJob() throws Exception { LOG.info("testGetNoteJob"); Note note = null; @@ -544,7 +544,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testRunParagraphWithParams() throws IOException, InterruptedException { + public void testRunParagraphWithParams() throws Exception { LOG.info("testRunParagraphWithParams"); Note note = null; @@ -586,7 +586,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testJobs() throws InterruptedException, IOException{ + public void testJobs() throws Exception { // create a note and a paragraph Note note = null; try { @@ -634,7 +634,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testCronDisable() throws InterruptedException, IOException{ + public void testCronDisable() throws Exception { Note note = null; try { // create a note and a paragraph diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java index dbecbf2..ef6c9b2 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java @@ -830,7 +830,7 @@ public class Note implements JsonSerializable { } } - public void runAll(AuthenticationInfo authenticationInfo, boolean blocking) { + public void runAll(AuthenticationInfo authenticationInfo, boolean blocking) throws Exception { setRunning(true); try { for (Paragraph p : getParagraphs()) { @@ -840,7 +840,8 @@ public class Note implements JsonSerializable { p.setAuthenticationInfo(authenticationInfo); if (!run(p.getId(), blocking)) { logger.warn("Skip running the remain notes because paragraph {} fails", p.getId()); - break; + throw new Exception("Fail to run note because paragraph " + p.getId() + " is failed, " + + p.getReturn()); } } } finally { diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/scheduler/CronJob.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/scheduler/CronJob.java index 7426750..1d2c3ff 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/scheduler/CronJob.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/scheduler/CronJob.java @@ -107,6 +107,10 @@ public class CronJob implements org.quartz.Job { cronExecutingUser, StringUtils.isEmpty(cronExecutingRoles) ? null : cronExecutingRoles, null); - note.runAll(authenticationInfo, true); + try { + note.runAll(authenticationInfo, true); + } catch (Exception e) { + logger.warn("Fail to run note", e); + } } } diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java index c5cfb8a..2cc9ba8 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java @@ -450,7 +450,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo } @Test - public void testRunAll() throws IOException { + public void testRunAll() throws Exception { Note note = notebook.createNote("note1", anonymous); // p1 @@ -822,8 +822,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo } @Test - public void testExportAndImportNote() throws IOException, CloneNotSupportedException, - InterruptedException, InterpreterException, SchedulerException, RepositoryException { + public void testExportAndImportNote() throws Exception { Note note = notebook.createNote("note1", anonymous); final Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -857,7 +856,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo } @Test - public void testCloneNote() throws IOException { + public void testCloneNote() throws Exception { Note note = notebook.createNote("note1", anonymous); final Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -888,7 +887,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo } @Test - public void testResourceRemovealOnParagraphNoteRemove() throws IOException { + public void testResourceRemovealOnParagraphNoteRemove() throws Exception { Note note = notebook.createNote("note1", anonymous); Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS); @@ -1155,8 +1154,7 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo } @Test - public void testAbortParagraphStatusOnInterpreterRestart() throws InterruptedException, - IOException, InterpreterException { + public void testAbortParagraphStatusOnInterpreterRestart() throws Exception { Note note = notebook.createNote("note1", anonymous); // create three paragraphs