Skip to content

Conversation

@AngersZhuuuu
Copy link
Contributor

@AngersZhuuuu AngersZhuuuu commented Dec 19, 2025

What changes were proposed in this pull request?

When submit failed, k8s case will stop SparkContext.
Here we already know the exit code, so here we stop SC should also pass the exitcode too.

Why are the changes needed?

keep same exit code for SC and whole app, help when checking the log

Does this PR introduce any user-facing change?

No

How was this patch tested?

Added UT

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the CORE label Dec 19, 2025
@AngersZhuuuu
Copy link
Contributor Author

ping @dongjoon-hyun @cloud-fan

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Do you think we can have a test coverage for this, @AngersZhuuuu ?

@AngersZhuuuu
Copy link
Contributor Author

Do you think we can have a test coverage for this, @AngersZhuuuu ?

Added, could you take a look?

@AngersZhuuuu
Copy link
Contributor Author

gentle ping @dongjoon-hyun @cloud-fan

assertResult(3)(runSparkSubmit(args, expectFailure = true))
}

test("SPARK-54774: k8s submit failed should keep same exit code with user code") {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for adding this, @AngersZhuuuu .

)
// The test application throws SparkUserAppException with exit code 42,
// so SparkContext.stop(42) should be called in k8s mode
assertResult(42)(runSparkSubmit(args, expectFailure = true))
Copy link
Member

Choose a reason for hiding this comment

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

This test case seems to pass without your patch, @AngersZhuuuu . Could you double-check this test case?

$ git diff master --stat
 core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

$ build/sbt "core/testOnly *.SparkSubmitSuite -- -z SPARK-54774"
[info] SparkSubmitSuite:
[info] - SPARK-54774: k8s submit failed should keep same exit code with user code (2 seconds, 926 milliseconds)
[info] Run completed in 3 seconds, 795 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 59 s, completed Dec 24, 2025, 6:29:30 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about current?

@dongjoon-hyun
Copy link
Member

BTW, it would be great if we can generalize the PR title by removing k8s or revising a little more.

@AngersZhuuuu AngersZhuuuu changed the title [SPARK-54774][CORE] k8s submit failed should keep same exit code with app exit code [SPARK-54774][CORE] Submit failed should keep same exit code with app exit code Dec 24, 2025
@AngersZhuuuu
Copy link
Contributor Author

BTW, it would be great if we can generalize the PR title by removing k8s or revising a little more.

Done

val listStatus = fileSystem.listStatus(testDirPath)
val logData = EventLogFileReader.openEventLog(listStatus.last.getPath, fileSystem)
Source.fromInputStream(logData)(Codec.UTF8).getLines().filter { line =>
line.contains("SparkListenerApplicationEnd")
Copy link
Member

Choose a reason for hiding this comment

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

a little bit hacky, possible to use a custom listener to achieve this?

BTW, will getLines close the resource correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a little bit hacky, possible to use a custom listener to achieve this?

BTW, will getLines close the resource correctly?

Looks like previous UT also use this, follow other UT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AngersZhuuuu
Copy link
Contributor Author

ping @dongjoon-hyun

@mridulm
Copy link
Contributor

mridulm commented Dec 30, 2025

@dongjoon-hyun:

BTW, it would be great if we can generalize the PR title by removing k8s or revising a little more.

This change is specific to k8s, right ? It is within a if (SparkMasterRegex.isK8s(args.master) &&
Did you mean it has applicability to other cases as well ? (if yes, that is not being addressed in the PR).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants