Skip to content

Commit fa50143

Browse files
uncleGensrowen
authored andcommitted
[SPARK-19739][CORE] propagate S3 session token to cluser
## What changes were proposed in this pull request? propagate S3 session token to cluser ## How was this patch tested? existing ut Author: uncleGen <[email protected]> Closes #17080 from uncleGen/SPARK-19739.
1 parent d556b31 commit fa50143

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@ class SparkHadoopUtil extends Logging {
8282
// the behavior of the old implementation of this code, for backwards compatibility.
8383
if (conf != null) {
8484
// Explicitly check for S3 environment variables
85-
if (System.getenv("AWS_ACCESS_KEY_ID") != null &&
86-
System.getenv("AWS_SECRET_ACCESS_KEY") != null) {
87-
val keyId = System.getenv("AWS_ACCESS_KEY_ID")
88-
val accessKey = System.getenv("AWS_SECRET_ACCESS_KEY")
89-
85+
val keyId = System.getenv("AWS_ACCESS_KEY_ID")
86+
val accessKey = System.getenv("AWS_SECRET_ACCESS_KEY")
87+
if (keyId != null && accessKey != null) {
9088
hadoopConf.set("fs.s3.awsAccessKeyId", keyId)
9189
hadoopConf.set("fs.s3n.awsAccessKeyId", keyId)
9290
hadoopConf.set("fs.s3a.access.key", keyId)
9391
hadoopConf.set("fs.s3.awsSecretAccessKey", accessKey)
9492
hadoopConf.set("fs.s3n.awsSecretAccessKey", accessKey)
9593
hadoopConf.set("fs.s3a.secret.key", accessKey)
94+
95+
val sessionToken = System.getenv("AWS_SESSION_TOKEN")
96+
if (sessionToken != null) {
97+
hadoopConf.set("fs.s3a.session.token", sessionToken)
98+
}
9699
}
97100
// Copy any "spark.hadoop.foo=bar" system properties into conf as "foo=bar"
98101
conf.getAll.foreach { case (key, value) =>

0 commit comments

Comments
 (0)