This is an automated email from the ASF dual-hosted git repository.

pdallig pushed a commit to branch branch-0.12
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/branch-0.12 by this push:
     new 7494becebb [ZEPPELIN-6241] Fail fast when default web app context 
fails to initialize due to missing resources
7494becebb is described below

commit 7494becebbcb359ad1ba7dfee46e420c7abae2e4
Author: ChanHo Lee <[email protected]>
AuthorDate: Thu Jul 17 22:33:47 2025 +0900

    [ZEPPELIN-6241] Fail fast when default web app context fails to initialize 
due to missing resources
    
    ### What is this PR for?
    Currently, the server keeps running even when all web app contexts fail to 
initialize due to missing files or directories for web resources.
    
    In my opinion, if the web resource path for the default web app context 
does not exist, it would be better to shut down the server immediately, since 
the context initialization will fail anyway. In such cases, other essential 
features like REST APIs and WebSocket communication also won’t work properly, 
so keeping the server running doesn’t seem meaningful.
    
    The absence of non-default web resources, however, seems generally 
acceptable. So this PR ensures that we only fail fast when the default web app 
context is missing its required resources.
    
    ### What type of PR is it?
    Improvement
    
    ### What is the Jira issue?
    - https://issues.apache.org/jira/browse/ZEPPELIN-6241
    
    ### How should this be tested?
    - Start the server with the default web app directory intentionally missing.
    - Verify that the server fails to start and exit immediately.
    - Ensure that non-default apps can still be missing without preventing 
startup
    
    ### Questions:
    * Does the license files need to update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Closes #4969 from tbonelee/fail-fast.
    
    Signed-off-by: Philipp Dallig <[email protected]>
    (cherry picked from commit 25cd340f1d831a38d41270684169a480379cec7a)
    Signed-off-by: Philipp Dallig <[email protected]>
---
 bin/common.sh                                      |  8 +++++--
 .../org/apache/zeppelin/server/ZeppelinServer.java | 25 ++++++++++------------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/bin/common.sh b/bin/common.sh
index 9aab5a693f..d86ad9071b 100644
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -46,7 +46,9 @@ if [[ -z "${ZEPPELIN_WAR}" ]]; then
     export ZEPPELIN_WAR="${ZEPPELIN_HOME}/zeppelin-web/dist"
   else
     ZEPPELIN_WAR=$(find -L "${ZEPPELIN_HOME}" -name "zeppelin-web-[0-9]*.war")
-    export ZEPPELIN_WAR
+    if [[ -n "${ZEPPELIN_WAR}" ]]; then
+      export ZEPPELIN_WAR
+    fi
   fi
 fi
 
@@ -55,7 +57,9 @@ if [[ -z "${ZEPPELIN_ANGULAR_WAR}" ]]; then
     export 
ZEPPELIN_ANGULAR_WAR="${ZEPPELIN_HOME}/zeppelin-web-angular/dist/zeppelin"
   else
     ZEPPELIN_ANGULAR_WAR=$(find -L "${ZEPPELIN_HOME}" -name 
"zeppelin-web-angular*.war")
-    export ZEPPELIN_ANGULAR_WAR
+    if [[ -n "${ZEPPELIN_ANGULAR_WAR}" ]]; then
+      export ZEPPELIN_ANGULAR_WAR
+    fi
   fi
 fi
 
diff --git 
a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java 
b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
index 27f926f7ec..42ebd8d033 100644
--- 
a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
+++ 
b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java
@@ -221,19 +221,14 @@ public class ZeppelinServer implements AutoCloseable {
         });
 
     // Multiple Web UI
-    String classicUiWebAppContextPath;
-    String newUiWebAppContextPath;
-    if (isNewUiDefault(zConf)) {
-      classicUiWebAppContextPath = NON_DEFAULT_CLASSIC_UI_WEB_APP_CONTEXT_PATH;
-      newUiWebAppContextPath = zConf.getServerContextPath();
-    } else {
-      classicUiWebAppContextPath = zConf.getServerContextPath();
-      newUiWebAppContextPath = NON_DEFAULT_NEW_UI_WEB_APP_CONTEXT_PATH;
-    }
+    String newUiWebAppContextPath = isNewUiDefault(zConf) ?  
zConf.getServerContextPath() : NON_DEFAULT_NEW_UI_WEB_APP_CONTEXT_PATH;
+    boolean newUiWebAppShouldExist = isNewUiDefault(zConf);
+    String classicUiWebAppContextPath = !isNewUiDefault(zConf) ? 
zConf.getServerContextPath() : NON_DEFAULT_CLASSIC_UI_WEB_APP_CONTEXT_PATH;
+    boolean classicUiWebAppShouldExist = !isNewUiDefault(zConf);
     final WebAppContext newUiWebApp = setupWebAppContext(contexts, zConf, 
zConf.getString(ConfVars.ZEPPELIN_ANGULAR_WAR),
-        newUiWebAppContextPath);
+        newUiWebAppContextPath, newUiWebAppShouldExist);
     final WebAppContext classicUiWebApp = setupWebAppContext(contexts, zConf, 
zConf.getString(ConfVars.ZEPPELIN_WAR),
-        classicUiWebAppContextPath);
+        classicUiWebAppContextPath, classicUiWebAppShouldExist);
 
     initWebApp(newUiWebApp);
     initWebApp(classicUiWebApp);
@@ -279,7 +274,7 @@ public class ZeppelinServer implements AutoCloseable {
       }
     } catch (Exception e) {
       LOGGER.error("Error while running jettyServer", e);
-      System.exit(-1);
+      shutdown(-1);
     }
 
     LOGGER.info("Done, zeppelin server started");
@@ -290,7 +285,7 @@ public class ZeppelinServer implements AutoCloseable {
       }
       if (!errorDatas.isEmpty()) {
         LOGGER.error("{} error(s) while starting - Termination", 
errorDatas.size());
-        System.exit(-1);
+        shutdown(-1);
       }
     } catch (InterruptedException e) {
       // Many fast unit tests interrupt the Zeppelin server at this point
@@ -588,10 +583,12 @@ public class ZeppelinServer implements AutoCloseable {
   }
 
   private static WebAppContext setupWebAppContext(
-      ContextHandlerCollection contexts, ZeppelinConfiguration zConf, String 
warPath, String contextPath) {
+      ContextHandlerCollection contexts, ZeppelinConfiguration zConf, String 
warPath, String contextPath, boolean shouldExist) {
     WebAppContext webApp = new WebAppContext();
     webApp.setContextPath(contextPath);
     LOGGER.info("warPath is: {}", warPath);
+    LOGGER.info("The file or directory for the warPath should exist: {}", 
shouldExist);
+    webApp.setThrowUnavailableOnStartupException(shouldExist);
     File warFile = new File(warPath);
     if (warFile.isDirectory()) {
       // Development mode, read from FS

Reply via email to