Skip to content

Commit 12a4096

Browse files
committed
Try and avoid the PV/PVC delete/create race condition during PVTestSuite by iterating on the name
1 parent a73b27c commit 12a4096

File tree

1 file changed

+8
-4
lines changed
  • resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest

1 file changed

+8
-4
lines changed

resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/PVTestsSuite.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite._
2828
private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
2929
import PVTestsSuite._
3030

31+
var i = 0
32+
3133
private def setupLocalStorageClass(): Unit = {
3234
val scBuilder = new StorageClassBuilder()
3335
.withKind("StorageClass")
@@ -53,11 +55,13 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
5355

5456
setupLocalStorageClass()
5557

58+
i = i + 1
59+
5660
val pvBuilder = new PersistentVolumeBuilder()
5761
.withKind("PersistentVolume")
5862
.withApiVersion("v1")
5963
.withNewMetadata()
60-
.withName("test-local-pv")
64+
.withName(f"{PV_NAME}-{i}")
6165
.endMetadata()
6266
.withNewSpec()
6367
.withCapacity(Map("storage" -> new Quantity("1Gi")).asJava)
@@ -81,7 +85,7 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
8185
.withKind("PersistentVolumeClaim")
8286
.withApiVersion("v1")
8387
.withNewMetadata()
84-
.withName(PVC_NAME)
88+
.withName(f"{PVC_NAME}-{i}")
8589
.endMetadata()
8690
.withNewSpec()
8791
.withAccessModes("ReadWriteOnce")
@@ -105,13 +109,13 @@ private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>
105109
kubernetesTestComponents
106110
.kubernetesClient
107111
.persistentVolumeClaims()
108-
.withName(PVC_NAME)
112+
.withName(f"{PVC_NAME}-{i}")
109113
.delete()
110114

111115
kubernetesTestComponents
112116
.kubernetesClient
113117
.persistentVolumes()
114-
.withName(PV_NAME)
118+
.withName(f"{PV_NAME}-{i}")
115119
.delete()
116120

117121
kubernetesTestComponents

0 commit comments

Comments
 (0)