You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/01 01:59:38 UTC

[GitHub] dongjoon-hyun commented on a change in pull request #23805: [SPARK-26420][k8s] Generate more unique IDs when creating k8s resource names.

dongjoon-hyun commented on a change in pull request #23805: [SPARK-26420][k8s] Generate more unique IDs when creating k8s resource names.
URL: https://github.com/apache/spark/pull/23805#discussion_r261457144
 
 

 ##########
 File path: resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/DriverServiceFeatureStepSuite.scala
 ##########
 @@ -92,25 +91,22 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Long prefixes should switch to using a generated name.") {
-    val clock = new ManualClock()
-    clock.setTime(10000)
     val sparkConf = new SparkConf(false)
       .set(KUBERNETES_NAMESPACE, "my-namespace")
-    val configurationStep = new DriverServiceFeatureStep(
-      KubernetesTestConf.createDriverConf(
-        sparkConf = sparkConf,
-        resourceNamePrefix = Some(LONG_RESOURCE_NAME_PREFIX),
-        labels = DRIVER_LABELS),
-      clock)
+    val kconf = KubernetesTestConf.createDriverConf(
+      sparkConf = sparkConf,
+      resourceNamePrefix = Some(LONG_RESOURCE_NAME_PREFIX),
+      labels = DRIVER_LABELS)
+    val configurationStep = new DriverServiceFeatureStep(kconf)
+
     val driverService = configurationStep
       .getAdditionalKubernetesResources()
       .head
       .asInstanceOf[Service]
-    val expectedServiceName = s"spark-10000${DriverServiceFeatureStep.DRIVER_SVC_POSTFIX}"
-    assert(driverService.getMetadata.getName === expectedServiceName)
-    val expectedHostName = s"$expectedServiceName.my-namespace.svc"
+    assert(!driverService.getMetadata.getName.startsWith(kconf.resourceNamePrefix))
 
 Review comment:
   The randomness is not about the whole string. It's only about a part of it. Specifically, this PR changes from `spark-10000-driver-svc` to `spark-b805936936efbcd5-driver-svc`.
   > The tests set the resource prefix to something that does not start with `spark-`, which is the prefix that is used in the auto-generated path.
   
   Previously, the randomness is determined by time, `10000`. Now, it has a better string, `b805936936efbcd5`.
   
   What I asked is adding the following two lines as a positive test case.
   ```scala
        assert(!driverService.getMetadata.getName.startsWith(kconf.resourceNamePrefix))
   +    assert(driverService.getMetadata.getName.startsWith("spark-"))
   +    assert(driverService.getMetadata.getName.endsWith("driver-svc"))
   ```
   
   The other stuff of this PR looks good.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org