Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ private[spark] class BasicExecutorFeatureStep(
val containerWithLimitCores = if (isDefaultProfile) {
executorLimitCores.map { limitCores =>
val executorCpuLimitQuantity = new Quantity(limitCores)
if (executorCpuLimitQuantity.compareTo(executorCpuQuantity) < 0) {
throw new SparkException(
"The executor cpu request should be less than or equal to cpu limit")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Should the request value and limit value be included in the error message?

}
new ContainerBuilder(executorContainerWithConfVolume)
.editResources()
.addToLimits("cpu", executorCpuLimitQuantity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class BasicExecutorFeatureStepSuite extends SparkFunSuite with BeforeAndAfter {
assert(error.contains("You must specify an amount for gpu"))
}

test("SPARK-52933: Verify if the executor cpu request exceeds limit") {
baseConf.set(KUBERNETES_EXECUTOR_REQUEST_CORES, "2")
baseConf.set(KUBERNETES_EXECUTOR_LIMIT_CORES, "1")
val error = intercept[SparkException] {
initDefaultProfile(baseConf)
val step = new BasicExecutorFeatureStep(newExecutorConf(), new SecurityManager(baseConf),
defaultProfile)
val executor = step.configurePod(SparkPod.initialPod())
}.getMessage()
assert(error.contains("The executor cpu request should be less than or equal to cpu limit"))
}

test("basic executor pod with resources") {
val fpgaResourceID = new ResourceID(SPARK_EXECUTOR_PREFIX, FPGA)
val gpuExecutorResourceID = new ResourceID(SPARK_EXECUTOR_PREFIX, GPU)
Expand Down