Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Conversation

lins05
Copy link

@lins05 lins05 commented Feb 4, 2017

Closes #85

@lins05 lins05 force-pushed the k8s-check-user-jars-files-existence branch from 7c47ac6 to 9914821 Compare February 4, 2017 09:12
Copy link

@mccheah mccheah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this, it indeed does make sense to push as much precondition checking as early as possible. I've left some comments.

@@ -661,6 +665,33 @@ private[spark] class Client(
}).toMap
}).getOrElse(Map.empty[String, String])
}

private def checkForUserJarsFilesExistence: Unit = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the trend has been for these kinds of precondition methods to pass the appropriate things to inspect as parameters, as opposed to inspecting the instance variables directly. We also have been running the validation inside of run() as opposed to in the constructor. See parseCustomLabels() for example.

private def checkForUserJarsFilesExistence: Unit = {
val conf = new Configuration

def existsOrAbort(uri: URI): Unit = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid nesting methods here. We can just inline this logic in the case statement of checkExistence.


def existsOrAbort(uri: URI): Unit = {
val path = new Path(uri)
if (!path.getFileSystem(conf).isFile(path)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we inline this in the case statement, it becomes clear that the scheme is of type file. Then instead of using getFileSystem we can just use an instance of java.io.File instance from the path component of the URI. This is the pattern we follow elsewhere, see buildSubmissionRequest().

}
}

def checkExistence(maybePaths: Option[String]): Unit = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, avoid nested methods. We can make this be the outermost method, and then run() can just call this three times, once for each of the appropriate fields to inspect.

Copy link

@ash211 ash211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support failing fast!

@@ -64,6 +68,7 @@ private[spark] class Client(
private val uploadedJars = sparkConf.get(KUBERNETES_DRIVER_UPLOAD_JARS).filter(_.nonEmpty)
private val uploadedFiles = sparkConf.get(KUBERNETES_DRIVER_UPLOAD_FILES).filter(_.nonEmpty)
uploadedFiles.foreach(validateNoDuplicateUploadFileNames)
checkForUserJarsFilesExistence
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put parentheses around zero-param methods like checkForUserJarsFilesExistence() -- I think this is Spark style

@lins05
Copy link
Author

lins05 commented Feb 8, 2017

@mccheah @ash211 updated.

@mccheah
Copy link

mccheah commented Feb 8, 2017

@aash anything else to add? Otherwise feel free to merge when the build passes.

@ash211 ash211 merged commit 69c8270 into apache-spark-on-k8s:k8s-support-alternate-incremental Feb 8, 2017
@ash211
Copy link

ash211 commented Feb 8, 2017

Thanks @lins05 !

ash211 pushed a commit that referenced this pull request Mar 8, 2017
)

* Check for user jars/files existence before creating the driver pod.

Close #85

* CR
foxish pushed a commit that referenced this pull request Jul 24, 2017
)

* Check for user jars/files existence before creating the driver pod.

Close #85

* CR
ifilonenko pushed a commit to ifilonenko/spark that referenced this pull request Feb 25, 2019
ifilonenko pushed a commit to ifilonenko/spark that referenced this pull request Feb 25, 2019
…pache-spark-on-k8s#86)

* Check for user jars/files existence before creating the driver pod.

Close apache-spark-on-k8s#85

* CR
puneetloya pushed a commit to puneetloya/spark that referenced this pull request Mar 11, 2019
…pache-spark-on-k8s#86)

* Check for user jars/files existence before creating the driver pod.

Close apache-spark-on-k8s#85

* CR
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants