Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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(s"The executor cpu request ($executorCpuQuantity) should be " +
s"less than or equal to cpu limit ($executorCpuLimitQuantity)")
}
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("cpu request (2) should be less than or equal to cpu limit (1)"))
}

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