Skip to content

Commit 40d63e0

Browse files
HADOOP-16568. S3A FullCredentialsTokenBinding fails if local credentials are unset. (#1441)
Contributed by Steve Loughran. Move the loading to deployUnbonded (where they are required) and add a safety check when a new DT is requested
1 parent 97c98ce commit 40d63e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/auth/delegation/FullCredentialsTokenBinding.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.net.URI;
2323
import java.util.Optional;
2424

25+
import com.google.common.base.Preconditions;
26+
2527
import org.apache.hadoop.conf.Configuration;
2628
import org.apache.hadoop.fs.s3a.AWSCredentialProviderList;
2729
import org.apache.hadoop.fs.s3a.S3AUtils;
@@ -73,7 +75,6 @@ public FullCredentialsTokenBinding() {
7375
@Override
7476
protected void serviceStart() throws Exception {
7577
super.serviceStart();
76-
loadAWSCredentials();
7778
}
7879

7980
/**
@@ -116,6 +117,7 @@ private void loadAWSCredentials() throws IOException {
116117
@Override
117118
public AWSCredentialProviderList deployUnbonded() throws IOException {
118119
requireServiceStarted();
120+
loadAWSCredentials();
119121
return new AWSCredentialProviderList(
120122
"Full Credentials Token Binding",
121123
new MarshalledCredentialProvider(
@@ -142,7 +144,8 @@ public AbstractS3ATokenIdentifier createTokenIdentifier(
142144
final EncryptionSecrets encryptionSecrets,
143145
final Text renewer) throws IOException {
144146
requireServiceStarted();
145-
147+
Preconditions.checkNotNull(
148+
awsCredentials, "No AWS credentials to use for a delegation token");
146149
return new FullCredentialsTokenIdentifier(getCanonicalUri(),
147150
getOwnerText(),
148151
renewer,

0 commit comments

Comments
 (0)