attilapiros commented on a change in pull request #30751:
URL: https://github.com/apache/spark/pull/30751#discussion_r541865925



##########
File path: 
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/backend/minikube/Minikube.scala
##########
@@ -56,60 +64,103 @@ private[spark] object Minikube extends Logging {
     if (oldMinikube.isEmpty) {
       getIfNewMinikubeStatus(statusString)
     } else {
-      val finalStatusString = oldMinikube
-        .head
-        .replaceFirst(MINIKUBE_VM_PREFIX, "")
-        .replaceFirst(MINIKUBE_PREFIX, "")
+      val statusLine = oldMinikube.head
+      val finalStatusString = if (statusLine.contains(MINIKUBE_VM_PREFIX)) {
+        statusLine.split(MINIKUBE_VM_PREFIX)(1)
+      } else {
+        statusLine.split(MINIKUBE_PREFIX)(1)
+      }
       MinikubeStatus.unapply(finalStatusString)
         .getOrElse(throw new IllegalStateException(s"Unknown status 
$statusString"))
     }
   }
 
   def getKubernetesClient: DefaultKubernetesClient = {
+    val versionArrayOpt = "\\d+\\.\\d+\\.\\d+".r
+      .findFirstIn(minikubeVersionString.split(VERSION_PREFIX)(1))
+      .map(_.split('.').map(_.toInt))
+
+    assert(versionArrayOpt.isDefined && versionArrayOpt.get.size == 3,
+      "Unexpected minikube version format: a three-part version number is 
expected")
+
+    val kubernetesConf = versionArrayOpt.get match {
+      case Array(x, y, z) =>
+        // comparing the versions as the kubectl command is only introduced in 
version v1.1.0:
+        // https://github.com/kubernetes/minikube/blob/v1.1.0/CHANGELOG.md
+        if (Ordering.Tuple3[Int, Int, Int].gteq((x, y, z), (1, 1, 0))) {

Review comment:
       Because of lexicographical ordering versions can be compared: 
   ```
   
   scala> Ordering.Tuple3[Int,Int,Int].gteq((1, 0, 1), (1, 1, 0))
   res0: Boolean = false
   
   scala> Ordering.Tuple3[Int,Int,Int].gteq((1, 1, 0), (1, 1, 0))
   res1: Boolean = true
   
   ```   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to