Skip to content

Commit

Permalink
Try and avoid the PV/PVC delete/create race condition during PVTestSu…
Browse files Browse the repository at this point in the history
…ite by iterating on the name
  • Loading branch information
holdenk committed Nov 18, 2021
1 parent a73b27c commit 12a4096
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite._
private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
import PVTestsSuite._

var i = 0

private def setupLocalStorageClass(): Unit = {
val scBuilder = new StorageClassBuilder()
.withKind("StorageClass")
Expand All @@ -53,11 +55,13 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>

setupLocalStorageClass()

i = i + 1

val pvBuilder = new PersistentVolumeBuilder()
.withKind("PersistentVolume")
.withApiVersion("v1")
.withNewMetadata()
.withName("test-local-pv")
.withName(f"{PV_NAME}-{i}")
.endMetadata()
.withNewSpec()
.withCapacity(Map("storage" -> new Quantity("1Gi")).asJava)
Expand All @@ -81,7 +85,7 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
.withKind("PersistentVolumeClaim")
.withApiVersion("v1")
.withNewMetadata()
.withName(PVC_NAME)
.withName(f"{PVC_NAME}-{i}")
.endMetadata()
.withNewSpec()
.withAccessModes("ReadWriteOnce")
Expand All @@ -105,13 +109,13 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
kubernetesTestComponents
.kubernetesClient
.persistentVolumeClaims()
.withName(PVC_NAME)
.withName(f"{PVC_NAME}-{i}")
.delete()

kubernetesTestComponents
.kubernetesClient
.persistentVolumes()
.withName(PV_NAME)
.withName(f"{PV_NAME}-{i}")
.delete()

kubernetesTestComponents
Expand Down

0 comments on commit 12a4096

Please sign in to comment.