Skip to content

Commit 057484e

Browse files
committed
[Fix-17908][Flink] Remove -sae parameter for APPLICATION mode to prevent task termination
The -sae (--shutdownOnAttachedExit) parameter is only suitable for attached mode where the CLI stays connected and waits for the job to complete. However, YARN Application mode runs in detached mode where the CLI exits after submission, causing the -sae parameter to trigger cluster shutdown and terminate the job unexpectedly. Changes: - Only add -sae parameter for non-APPLICATION deploy modes - Update test cases to reflect the new behavior
1 parent 39168c8 commit 057484e

File tree

3 files changed

+8
-3
lines changed
  • dolphinscheduler-task-plugin

3 files changed

+8
-3
lines changed

dolphinscheduler-task-plugin/dolphinscheduler-task-flink-stream/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public void testRunJarInApplicationMode() throws Exception {
6868
FlinkStreamParameters flinkParameters = buildTestFlinkParametersWithDeployMode(FlinkDeployMode.APPLICATION);
6969
List<String> commandLine = FlinkArgsUtils.buildRunCommandLine(buildTestTaskExecutionContext(), flinkParameters);
7070

71+
// APPLICATION mode should NOT include -sae parameter (detached mode on YARN)
7172
Assertions.assertEquals(
72-
"${FLINK_HOME}/bin/flink run-application -t yarn-application -ys 4 -ynm demo-app-name -yjm 1024m -ytm 1024m -p 4 -sae -c org.example.Main /opt/job.jar",
73+
"${FLINK_HOME}/bin/flink run-application -t yarn-application -ys 4 -ynm demo-app-name -yjm 1024m -ytm 1024m -p 4 -c org.example.Main /opt/job.jar",
7374
joinStringListWithSpace(commandLine));
7475
}
7576

dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ private static List<String> buildRunCommandLineForOthers(TaskExecutionContext ta
267267
// If the job is submitted in attached mode, perform a best-effort cluster shutdown when the CLI is terminated
268268
// abruptly
269269
// The task status will be synchronized with the cluster job status
270-
args.add(FlinkConstants.FLINK_SHUTDOWN_ON_ATTACHED_EXIT); // -sae
270+
// Note: -sae should NOT be used for APPLICATION mode, as it runs in detached mode on YARN
271+
if (deployMode != FlinkDeployMode.APPLICATION) {
272+
args.add(FlinkConstants.FLINK_SHUTDOWN_ON_ATTACHED_EXIT); // -sae
273+
}
271274

272275
// -s -yqu -yat -yD -D
273276
if (StringUtils.isNotEmpty(others)) {

dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public void testRunJarInApplicationMode() throws Exception {
6868
FlinkParameters flinkParameters = buildTestFlinkParametersWithDeployMode(FlinkDeployMode.APPLICATION);
6969
List<String> commandLine = FlinkArgsUtils.buildRunCommandLine(buildTestTaskExecutionContext(), flinkParameters);
7070

71+
// APPLICATION mode should NOT include -sae parameter (detached mode on YARN)
7172
Assertions.assertEquals(
72-
"${FLINK_HOME}/bin/flink run-application -t yarn-application -ys 4 -ynm demo-app-name -yjm 1024m -ytm 1024m -p 4 -sae -c org.example.Main /opt/job.jar",
73+
"${FLINK_HOME}/bin/flink run-application -t yarn-application -ys 4 -ynm demo-app-name -yjm 1024m -ytm 1024m -p 4 -c org.example.Main /opt/job.jar",
7374
joinStringListWithSpace(commandLine));
7475
}
7576

0 commit comments

Comments
 (0)