From 4f0db872a089257f1e894060e1757f9e5b973142 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Thu, 3 Jun 2021 10:41:11 -0500 Subject: [PATCH] [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 Signed-off-by: Mridul Muralidharan gmail.com> --- .../spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala index 3349e0c147..606339aec9 100644 --- a/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala +++ b/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsAllocator.scala @@ -390,8 +390,8 @@ private[spark] class ExecutorPodsAllocator( private def replacePVCsIfNeeded( pod: Pod, resources: Seq[HasMetadata], - reusablePVCs: mutable.Buffer[PersistentVolumeClaim]) = { - val replacedResources = mutable.ArrayBuffer[HasMetadata]() + reusablePVCs: mutable.Buffer[PersistentVolumeClaim]): Seq[HasMetadata] = { + val replacedResources = mutable.Set[HasMetadata]() resources.foreach { case pvc: PersistentVolumeClaim => // Find one with the same storage class and size. @@ -407,7 +407,7 @@ private[spark] class ExecutorPodsAllocator( } if (volume.nonEmpty) { val matchedPVC = reusablePVCs.remove(index) - replacedResources.append(pvc) + replacedResources.add(pvc) logInfo(s"Reuse PersistentVolumeClaim ${matchedPVC.getMetadata.getName}") volume.get.getPersistentVolumeClaim.setClaimName(matchedPVC.getMetadata.getName) }