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

    https://github.com/apache/spark/pull/6360#discussion_r31769508
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -296,6 +284,53 @@ private[spark] class Client(
         }
     
         /**
    +     * Distribute a file to the cluster.
    +     *
    +     * @param path URI of the file to distribute.
    +     * @param resType Type of resource being distributed.
    +     * @param destName Name of the file in the distributed cache.
    +     * @param targetDir Subdirectory where to place the file.
    +     * @param appMasterOnly Whether to distribute only to the AM.
    +     * @return A 2-tuple. First item is whether the file is a "local:" 
URI. Second item is the
    +     *         localized path for non-local paths, or the input `path` for 
local paths.
    +     */
    +    def distribute(
    +        path: String,
    +        resType: LocalResourceType = LocalResourceType.FILE,
    +        destName: Option[String] = None,
    +        targetDir: Option[String] = None,
    +        appMasterOnly: Boolean = false): (Boolean, String) = {
    +      val localURI = new URI(path.trim())
    +      if (localURI.getScheme != LOCAL_SCHEME) {
    +        if (addDistributedUri(localURI)) {
    +          val localPath = getQualifiedLocalPath(localURI, hadoopConf)
    +          val linkname = targetDir.map(_ + "/").getOrElse("") +
    +            
destName.orElse(Option(localURI.getFragment())).getOrElse(localPath.getName())
    +          val destPath = copyFileToRemote(dst, localPath, replication)
    +          distCacheMgr.addResource(
    +            fs, hadoopConf, destPath, localResources, resType, linkname, 
statCache,
    +            appMasterOnly = appMasterOnly)
    +          (false, linkname)
    +        } else {
    +          (false, null)
    +        }
    +      } else {
    +        (true, path.trim())
    +      }
    +    }
    +
    +    // If we passed in a keytab, make sure we copy the keytab to the 
staging directory on
    +    // HDFS, and setup the relevant environment vars, so the AM can login 
again.
    +    if (loginFromKeytab) {
    +      logInfo("To enable the AM to login from keytab, credentials are 
being copied over to the AM" +
    +        " via the YARN Secure Distributed Cache.")
    +      val (_, localizedPath) = distribute(args.keytab,
    +        destName = Some(sparkConf.get("spark.yarn.keytab")),
    +        appMasterOnly = true)
    +      require(localizedPath != null)
    --- End diff --
    
    do we require here because the key tab should only be distributed once? If 
so can you add a comment about that here can maybe a fail message for the 
require?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to