-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a pre-installed Minikube instance -- porting over logic from PR 521 #14
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3d152c9
initial logic needed for porting PR 521
ifilonenko 6a014fb
merge conflicts
ifilonenko 22668e3
remove spark.version in pom
ifilonenko a59339c
minor styling
ifilonenko 21fc0d1
handling flags, readmes, and POM changes
ifilonenko c777d2c
resolve issues with minikube and some comment resolution
ifilonenko 55e97ea
updated readme
ifilonenko 7369772
config values
ifilonenko 3a2b4d8
Merge remote-tracking branch 'origin/master' into 'ifilonenko/master'
mccheah 7470472
Modify SparkDockerImageBuilder so it can delete docker images
mccheah 047b2a2
Move the docker manager in git
mccheah 6c32d8f
Merge remote-tracking branch 'ifilonenko/master' into HEAD
mccheah 792476f
Address more comments.
mccheah 103d507
Address more comments
mccheah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,74 +20,38 @@ import java.nio.file.Paths | |
|
||
import io.fabric8.kubernetes.client.{ConfigBuilder, DefaultKubernetesClient} | ||
|
||
import org.apache.commons.lang3.SystemUtils | ||
import org.apache.spark.deploy.k8s.integrationtest.{Logging, ProcessUtils} | ||
|
||
// TODO support windows | ||
private[spark] object Minikube extends Logging { | ||
private val MINIKUBE_EXECUTABLE_DEST = if (SystemUtils.IS_OS_MAC_OSX) { | ||
Paths.get("target", "minikube-bin", "darwin-amd64", "minikube").toFile | ||
} else if (SystemUtils.IS_OS_WINDOWS) { | ||
throw new IllegalStateException("Executing Minikube based integration tests not yet " + | ||
" available on Windows.") | ||
} else { | ||
Paths.get("target", "minikube-bin", "linux-amd64", "minikube").toFile | ||
} | ||
|
||
private val EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE = "Minikube is not downloaded, expected at " + | ||
s"${MINIKUBE_EXECUTABLE_DEST.getAbsolutePath}" | ||
|
||
private val MINIKUBE_STARTUP_TIMEOUT_SECONDS = 60 | ||
|
||
// NOTE: This and the following methods are synchronized to prevent deleteMinikube from | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are deleting this note. Maybe we don't need "synchronized" any more. Kill "synchronized" below? |
||
// destroying the minikube VM while other methods try to use the VM. | ||
// Such a race condition can corrupt the VM or some VM provisioning tools like VirtualBox. | ||
def startMinikube(): Unit = synchronized { | ||
assert(MINIKUBE_EXECUTABLE_DEST.exists(), EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE) | ||
if (getMinikubeStatus != MinikubeStatus.RUNNING) { | ||
executeMinikube("start", "--memory", "6000", "--cpus", "8") | ||
} else { | ||
logInfo("Minikube is already started.") | ||
} | ||
} | ||
|
||
def getMinikubeIp: String = synchronized { | ||
assert(MINIKUBE_EXECUTABLE_DEST.exists(), EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE) | ||
def getMinikubeIp: String = { | ||
val outputs = executeMinikube("ip") | ||
.filter(_.matches("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$")) | ||
assert(outputs.size == 1, "Unexpected amount of output from minikube ip") | ||
outputs.head | ||
} | ||
|
||
def getMinikubeStatus: MinikubeStatus.Value = synchronized { | ||
assert(MINIKUBE_EXECUTABLE_DEST.exists(), EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE) | ||
def getMinikubeStatus: MinikubeStatus.Value = { | ||
val statusString = executeMinikube("status") | ||
.filter(_.contains("minikube: ")) | ||
.filter(line => line.contains("minikubeVM: ") || line.contains("minikube:")) | ||
.head | ||
.replaceFirst("minikubeVM: ", "") | ||
.replaceFirst("minikube: ", "") | ||
MinikubeStatus.unapply(statusString) | ||
.getOrElse(throw new IllegalStateException(s"Unknown status $statusString")) | ||
} | ||
|
||
def getDockerEnv: Map[String, String] = synchronized { | ||
assert(MINIKUBE_EXECUTABLE_DEST.exists(), EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE) | ||
def getDockerEnv: Map[String, String] = { | ||
executeMinikube("docker-env", "--shell", "bash") | ||
.filter(_.startsWith("export")) | ||
.map(_.replaceFirst("export ", "").split('=')) | ||
.map(arr => (arr(0), arr(1).replaceAllLiterally("\"", ""))) | ||
.toMap | ||
} | ||
|
||
def deleteMinikube(): Unit = synchronized { | ||
assert(MINIKUBE_EXECUTABLE_DEST.exists, EXPECTED_DOWNLOADED_MINIKUBE_MESSAGE) | ||
if (getMinikubeStatus != MinikubeStatus.NONE) { | ||
executeMinikube("delete") | ||
} else { | ||
logInfo("Minikube was already not running.") | ||
} | ||
} | ||
|
||
def getKubernetesClient: DefaultKubernetesClient = synchronized { | ||
def getKubernetesClient: DefaultKubernetesClient = { | ||
val kubernetesMaster = s"https://${getMinikubeIp}:8443" | ||
val userHome = System.getProperty("user.home") | ||
val kubernetesConf = new ConfigBuilder() | ||
|
@@ -105,13 +69,8 @@ private[spark] object Minikube extends Logging { | |
} | ||
|
||
private def executeMinikube(action: String, args: String*): Seq[String] = { | ||
if (!MINIKUBE_EXECUTABLE_DEST.canExecute) { | ||
if (!MINIKUBE_EXECUTABLE_DEST.setExecutable(true)) { | ||
throw new IllegalStateException("Failed to make the Minikube binary executable.") | ||
} | ||
} | ||
ProcessUtils.executeProcess(Array(MINIKUBE_EXECUTABLE_DEST.getAbsolutePath, action) ++ args, | ||
MINIKUBE_STARTUP_TIMEOUT_SECONDS) | ||
ProcessUtils.executeProcess( | ||
Array("minikube", action) ++ args, MINIKUBE_STARTUP_TIMEOUT_SECONDS) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integration-test/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/config.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.k8s.integrationtest | ||
|
||
package object config { | ||
val KUBERNETES_TEST_DOCKER_TAG_SYSTEM_PROPERTY = "spark.kubernetes.test.imageDockerTag" | ||
val DRIVER_DOCKER_IMAGE = "spark.kubernetes.driver.container.image" | ||
val EXECUTOR_DOCKER_IMAGE = "spark.kubernetes.executor.container.image" | ||
val INIT_CONTAINER_DOCKER_IMAGE = "spark.kubernetes.initcontainer.container.image" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not generate a random ID like minikube backend code does? i.e.
UUID.randomUUID().toString.replaceAll("-", "")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Minikube case we're building these images from scratch. In the GCE case, we don't create a Docker manager and hence are not building the images there. But this in itself seems to contradict this section of our readme:
which indicates that GCE-backed tests should be building images as well. Is this correct @foxish?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That readme section is meant to highlight that we push the images to an image repository only in the cloud testing case, and don't have to in the minikube case since the images are built in the minikube VM's docker environment. That documentation pertains only to the use of the script, which avoids using maven for building images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem then with using a random ID tag here is that it's impossible for this tag to actually match anything. Using "latest" at least guarantees that we pick up some image in the default case.
We can be more strict here and require the tag be explicitly specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking a little closer I think the miscommunication is because the docker image manager isn't serving the image tag but is instead being handed the tag by the test backend. The responsibilities thus aren't clear and the coupling of the provision of a custom tag vs. a generated tag, and how that influences whether or not images are built or deleted, is unclear.
I'm moving the generation of the tag vs. using the user-provided one into the docker manager. This should hopefully clarify the connection.