Skip to content

Conversation

@chris-fast
Copy link

@chris-fast chris-fast commented Jan 27, 2026

What is the purpose of the change

Fixes #17908

The -sae (--shutdownOnAttachedExit) parameter was causing Flink tasks in YARN Application mode to terminate unexpectedly. Based on reviewer feedback, this parameter is now configurable via the UI instead of being hardcoded based on deploy mode.

Root Cause

Previously, the -sae parameter was automatically added for all non-APPLICATION modes. This hardcoded behavior didn't provide users with the flexibility to control this parameter based on their specific use cases.

Solution

Made the -sae parameter fully configurable through the UI:

  • Added a new shutdownOnAttachedExit field to FlinkParameters
  • Changed from hardcoded deployMode check to explicit configuration
  • Added UI switch control in the Flink task form
  • Default value: false (disabled for safety and backward compatibility)

Brief changelog

  • Added shutdownOnAttachedExit field to FlinkParameters with enhanced JavaDoc
  • Modified FlinkArgsUtils.buildRunCommandLine() to use configuration-based logic
  • Added UI switch control in Flink task form (positioned after Yarn Queue field)
  • Added comprehensive test cases covering all scenarios (null, false, true, APPLICATION mode)
  • Added Chinese and English i18n translations

Verifying this change

  • Code compilation pass
  • Unit tests updated and passing
  • Follows the project's code style (spotless)
  • Backward compatibility maintained

Test Cases Coverage

New test cases added:

  1. testRunJarWithShutdownOnAttachedExitEnabled() - Explicitly enabled (true)
  2. testRunJarWithShutdownOnAttachedExitDisabled() - Explicitly disabled (false)
  3. testRunJarWithShutdownOnAttachedExitInApplicationMode() - APPLICATION mode with enabled

Existing tests updated:

  • All default behavior tests now expect no -sae parameter
  • Maintains test coverage for CLUSTER, LOCAL, and APPLICATION modes

Behavior Matrix

Scenario shutdownOnAttachedExit deployMode -sae Added?
New task (default) null ANY No (safe default)
Existing task null ANY No (backward compatible)
Explicitly disabled false ANY No
Explicitly enabled true CLUSTER Yes
Explicitly enabled true LOCAL Yes
Explicitly enabled true APPLICATION Yes (user's choice)

Backward Compatibility

✅ Fully backward compatible:

  • Uses Boolean type (three-state: null/false/true)
  • null value represents existing tasks (no -sae parameter)
  • false value represents explicitly disabled
  • true value represents explicitly enabled
  • All existing Flink tasks continue to work without modification

UI Changes

A new switch control "Shutdown On Attached Exit" has been added to the Flink task configuration form:

  • Located between "Yarn Queue" and "Main Arguments" fields
  • Default: disabled (false)
  • When enabled, adds -sae parameter to Flink command
  • Translation provided in both Chinese and English

Related issues

Fixes #17908

…ent 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
Comment on lines 270 to 273
// Note: -sae should NOT be used for APPLICATION mode, as it runs in detached mode on YARN
if (deployMode != FlinkDeployMode.APPLICATION) {
args.add(FlinkConstants.FLINK_SHUTDOWN_ON_ATTACHED_EXIT); // -sae
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make it configurable in UI and set it as off by default.

@SbloodyS SbloodyS changed the title Fix 17908 flink sae parameter [Fix-17908] Flink sae parameter issue Jan 27, 2026
@SbloodyS SbloodyS added first time contributor First-time contributor improvement make more easy to user or prompt friendly labels Jan 27, 2026
@SbloodyS SbloodyS changed the title [Fix-17908] Flink sae parameter issue [Improvement-17908] Flink sae parameter issue Jan 27, 2026
@SbloodyS SbloodyS changed the title [Improvement-17908] Flink sae parameter issue [Improvement-17908] Flink sae parameter improvement Jan 27, 2026
@SbloodyS SbloodyS added this to the 3.4.1 milestone Jan 27, 2026
@chris-fast
Copy link
Author

Hi @SbloodyS , thank you for the review feedback!

I understand the requirement to make the -sae parameter configurable in UI with default as off.

Current Situation

The current PR removes -sae for APPLICATION mode only:

if (deployMode != FlinkDeployMode.APPLICATION) {
    args.add(FlinkConstants.FLINK_SHUTDOWN_ON_ATTACHED_EXIT);
}

Proposed Solution

I'''d like to propose adding a UI-configurable option for the -sae parameter:

Implementation Plan

  1. Backend Changes:

    • Add Boolean shutdownOnAttachedExit field to FlinkParameters.java
    • Modify FlinkArgsUtils.java to use this config:
      if (Boolean.TRUE.equals(flinkParameters.getShutdownOnAttachedExit())) {
          args.add(FlinkConstants.FLINK_SHUTDOWN_ON_ATTACHED_EXIT);
      }
    • Default value: null (disabled, parameter not added)
  2. Frontend Changes:

    • Add a checkbox in Flink task configuration UI
    • Label: "Shutdown on Attached Exit" (with tooltip explaining)
    • Default: unchecked (off by default as requested)

Benefits

  • ✅ User can explicitly control -sae parameter
  • ✅ Backward compatible (null = no parameter added)
  • ✅ Default OFF as requested
  • ✅ Clear UI indication

Questions

Before proceeding with implementation, I'''d like to confirm:

  1. Default behavior: Should existing tasks (without this field) have -sae disabled by default?

    • My proposal: Yes, default to disabled (null/false)
  2. UI placement: Should the checkbox be shown for all deploy modes or only non-APPLICATION modes?

    • My proposal: Show for all modes, user has full control
  3. Alternative: Would you prefer a different approach?

Looking forward to your feedback! Thanks!

@SbloodyS
Copy link
Member

@chris-fast Excellent. Your description is very accurate and correct. Please modify this PR according to your description.

…h default off

Changes:
- Add shutdownOnAttachedExit field to FlinkParameters with enhanced JavaDoc
- Change logic from hardcoded deployMode check to configuration-based
- Add UI switch control in Flink task form (positioned after Yarn Queue)
- Add comprehensive test cases for all scenarios (null, false, true, APPLICATION mode)
- Add Chinese and English i18n translations
- Default value: false (disabled for safety and backward compatibility)

This addresses the reviewer's feedback to make the -sae parameter
configurable via UI instead of hardcoded behavior based on deploy mode.

The implementation uses Boolean type (three-state: null/false/true) to
ensure backward compatibility with existing tasks.
@github-actions github-actions bot added the UI ui and front end related label Jan 28, 2026
@chris-fast chris-fast changed the title [Improvement-17908] Flink sae parameter improvement [Improvement-17908][Flink] Make -sae parameter configurable in UI with default off Jan 28, 2026
@chris-fast
Copy link
Author

@SbloodyS I've updated the PR according to the plan, PTAL. Thanks!

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend first time contributor First-time contributor improvement make more easy to user or prompt friendly test UI ui and front end related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] [Flink] sae parameter will cause the task to be killed

2 participants