[SPARK-35416][K8S][FOLLOWUP] Use Set instead of ArrayBuffer
### What changes were proposed in this pull request? This is a follow-up of https://github.com/apache/spark/pull/32564 . ### Why are the changes needed? To use Set instead of ArrayBuffer and add a return type. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. Closes #32758 from dongjoon-hyun/SPARK-35416-2. Authored-by: Dongjoon Hyun <dhyun@apple.com> Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
This commit is contained in:
parent
cfde117c6f
commit
4f0db872a0
|
@ -390,8 +390,8 @@ private[spark] class ExecutorPodsAllocator(
|
||||||
private def replacePVCsIfNeeded(
|
private def replacePVCsIfNeeded(
|
||||||
pod: Pod,
|
pod: Pod,
|
||||||
resources: Seq[HasMetadata],
|
resources: Seq[HasMetadata],
|
||||||
reusablePVCs: mutable.Buffer[PersistentVolumeClaim]) = {
|
reusablePVCs: mutable.Buffer[PersistentVolumeClaim]): Seq[HasMetadata] = {
|
||||||
val replacedResources = mutable.ArrayBuffer[HasMetadata]()
|
val replacedResources = mutable.Set[HasMetadata]()
|
||||||
resources.foreach {
|
resources.foreach {
|
||||||
case pvc: PersistentVolumeClaim =>
|
case pvc: PersistentVolumeClaim =>
|
||||||
// Find one with the same storage class and size.
|
// Find one with the same storage class and size.
|
||||||
|
@ -407,7 +407,7 @@ private[spark] class ExecutorPodsAllocator(
|
||||||
}
|
}
|
||||||
if (volume.nonEmpty) {
|
if (volume.nonEmpty) {
|
||||||
val matchedPVC = reusablePVCs.remove(index)
|
val matchedPVC = reusablePVCs.remove(index)
|
||||||
replacedResources.append(pvc)
|
replacedResources.add(pvc)
|
||||||
logInfo(s"Reuse PersistentVolumeClaim ${matchedPVC.getMetadata.getName}")
|
logInfo(s"Reuse PersistentVolumeClaim ${matchedPVC.getMetadata.getName}")
|
||||||
volume.get.getPersistentVolumeClaim.setClaimName(matchedPVC.getMetadata.getName)
|
volume.get.getPersistentVolumeClaim.setClaimName(matchedPVC.getMetadata.getName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue