Github user ifilonenko commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22805#discussion_r227499598
  
    --- Diff: 
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/backend/docker/DockerForDesktopBackend.scala
 ---
    @@ -0,0 +1,68 @@
    +package org.apache.spark.deploy.k8s.integrationtest.backend.docker
    +
    +import java.nio.file.Paths
    +
    +import io.fabric8.kubernetes.client.{Config, DefaultKubernetesClient}
    +import org.apache.spark.deploy.k8s.integrationtest.ProcessUtils
    +import 
org.apache.spark.deploy.k8s.integrationtest.backend.IntegrationTestBackend
    +
    +private[spark] object DockerForDesktopBackend extends 
IntegrationTestBackend {
    +
    +  private val KUBECTL_STARTUP_TIMEOUT_SECONDS = 15
    +
    +  private var defaultClient: DefaultKubernetesClient = _
    +  private var initialContext = ""
    +
    +  private def getCurrentContext: String = {
    +    val outputs = executeKubectl("config", "current-context")
    +    assert(outputs.size == 1, "Unexpected amount of output from kubectl 
config current-context")
    +    outputs.head
    +  }
    +
    +  private def setContext(context: String): Unit = {
    +    val outputs = executeKubectl("config", "use-context", context)
    +    assert(outputs.size == 1, "Unexpected amount of output from kubectl 
config use-context")
    +    val errors = outputs.filter(_.startsWith("error"))
    +    assert(errors.size == 0, s"Received errors from kubectl: 
${errors.head}")
    +  }
    +
    +  override def initialize(): Unit = {
    +    // Switch context if necessary
    +    // TODO: If we were using Fabric 8 client 3.1.0 then we could
    +    // instead just use the overload of autoConfigure() that takes the
    +    // desired context avoiding the need to interact with kubectl at all
    +    initialContext = getCurrentContext
    --- End diff --
    
    I would definitely not be opposed. This work will cause a bit of overhead 
in little refactorings all over the code-base tho, but shouldn't be a problem. 
I had already gotten started with that, but if you or @skonto want to take 
over, that would be great. Especially given that this would remove the need to 
use `kubectl`.
    +1 on this


---

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

Reply via email to