Skip to content

Commit f3cbdc3

Browse files
committed
HADOOP-16568. S3A FullCredentialsTokenBinding fails if local credentials are unset.
Move the loading to deployUnbonded (where they are required) and add a safety check when a new DT is requested Change-Id: I516368c2c4a558a2a86e8cf107f77f1e40338261
1 parent 95010a4 commit f3cbdc3

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;
@@ -72,7 +74,6 @@ public FullCredentialsTokenBinding() {
7274
@Override
7375
protected void serviceStart() throws Exception {
7476
super.serviceStart();
75-
loadAWSCredentials();
7677
}
7778

7879
/**
@@ -115,6 +116,7 @@ private void loadAWSCredentials() throws IOException {
115116
@Override
116117
public AWSCredentialProviderList deployUnbonded() throws IOException {
117118
requireServiceStarted();
119+
loadAWSCredentials();
118120
return new AWSCredentialProviderList(
119121
"Full Credentials Token Binding",
120122
new MarshalledCredentialProvider(
@@ -140,7 +142,8 @@ public AbstractS3ATokenIdentifier createTokenIdentifier(
140142
final Optional<RoleModel.Policy> policy,
141143
final EncryptionSecrets encryptionSecrets) throws IOException {
142144
requireServiceStarted();
143-
145+
Preconditions.checkNotNull(
146+
awsCredentials, "No AWS credentials to use for a delegation token");
144147
return new FullCredentialsTokenIdentifier(getCanonicalUri(),
145148
getOwnerText(),
146149
awsCredentials,

0 commit comments

Comments
 (0)