zjffdu commented on a change in pull request #4116:
URL: https://github.com/apache/zeppelin/pull/4116#discussion_r724986978



##########
File path: 
zeppelin-plugins/launcher/flink/src/main/java/org/apache/zeppelin/interpreter/launcher/FlinkInterpreterLauncher.java
##########
@@ -59,14 +62,29 @@ public FlinkInterpreterLauncher(ZeppelinConfiguration 
zConf, RecoveryStorage rec
     normalizeConfiguration(context);
 
     String flinkExecutionMode = 
context.getProperties().getProperty("flink.execution.mode");
-    // yarn application mode specific logic
-    if ("yarn-application".equalsIgnoreCase(flinkExecutionMode)) {
-      updateEnvsForYarnApplicationMode(envs, context);
+    if (!FLINK_EXECUTION_MODES.contains(flinkExecutionMode)) {
+      throw new IOException("Not valid flink.execution.mode: " +
+              flinkExecutionMode + ", valid modes ares: " +
+              FLINK_EXECUTION_MODES.stream().collect(Collectors.joining(", 
")));
+    }
+    // application mode specific logic
+    if (isApplicationMode(flinkExecutionMode)) {
+      updateEnvsForApplicationMode(flinkExecutionMode, envs, context);
     }
 
-    String flinkAppJar = chooseFlinkAppJar(flinkHome);
-    LOGGER.info("Choose FLINK_APP_JAR: {}", flinkAppJar);
-    envs.put("FLINK_APP_JAR", flinkAppJar);
+    if (isK8sApplicationMode(flinkExecutionMode)) {
+      String flinkAppJar = 
context.getProperties().getProperty("flink.app.jar");
+      if (StringUtils.isBlank(flinkAppJar)) {
+        throw new IOException("flink.app.jar is not specified for 
kubernetes-application mode");
+      }
+      envs.put("FLINK_APP_JAR", flinkAppJar);
+      LOGGER.info("K8s application's FLINK_APP_JAR : " + flinkAppJar);
+      context.getProperties().put("zeppelin.interpreter.forceShutdown", 
"true");

Review comment:
       Fixed

##########
File path: 
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
##########
@@ -380,11 +388,14 @@ public void createInterpreter(String interpreterGroupId, 
String sessionId, Strin
               replClass.getConstructor(new Class[]{Properties.class});
       Interpreter interpreter = constructor.newInstance(p);
       interpreter.setClassloaderUrls(new URL[]{});
-      LOGGER.info("Instantiate interpreter {}", className);
+
       interpreter.setInterpreterGroup(interpreterGroup);
       interpreter.setUserName(userName);
 
       interpreterGroup.addInterpreterToSession(new 
LazyOpenInterpreter(interpreter), sessionId);
+
+      this.isForceShutdown = 
Boolean.parseBoolean(properties.getOrDefault("zeppelin.interpreter.forceShutdown",
 "false"));

Review comment:
       Fixed

##########
File path: 
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
##########
@@ -142,6 +141,12 @@
   private ScheduledExecutorService resultCleanService = 
Executors.newSingleThreadScheduledExecutor();
 
   private boolean isTest;
+  // Whether calling System.exit to force shutdown interpreter process.
+  // In Flink K8s application mode, RemoteInterpreterServer#main is called via 
reflection by flink framework.
+  // We should not call System.exit in this scenario when 
RemoteInterpreterServer is stopped,
+  // Otherwise flink will think flink job is exited abnormally and will try to 
restart this
+  // pod (RemoteInterpreterServer)
+  private boolean isForceShutdown = false;

Review comment:
       Fixed

##########
File path: 
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
##########
@@ -701,8 +712,10 @@ public void run() {
       }
 
       if (server.isServing()) {
-        LOGGER.info("Force shutting down");
-        System.exit(1);
+        if (!isForceShutdown) {

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to