Skip to content

Commit ff3fade

Browse files
committed
HADOOP-19654. Can't use path access and FIPS endpoint (documented; not a bug)
1 parent 9a5ee3e commit ff3fade

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.apache.hadoop.classification.InterfaceStability;
5858
import org.apache.hadoop.conf.Configuration;
5959
import org.apache.hadoop.conf.Configured;
60-
import org.apache.hadoop.fs.s3a.impl.RegionResolution;
6160
import org.apache.hadoop.fs.s3a.statistics.impl.AwsStatisticsCollector;
6261
import org.apache.hadoop.fs.store.LogExactlyOnce;
6362

@@ -419,8 +418,24 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void
419418
*/
420419
protected static URI getS3Endpoint(String endpoint, final Configuration conf) {
421420

422-
return RegionResolution.getS3Endpoint(endpoint,
423-
conf.getBoolean(SECURE_CONNECTIONS, DEFAULT_SECURE_CONNECTIONS));
421+
boolean secureConnections = conf.getBoolean(SECURE_CONNECTIONS, DEFAULT_SECURE_CONNECTIONS);
422+
423+
String protocol = secureConnections ? "https" : "http";
424+
425+
if (endpoint == null || endpoint.isEmpty()) {
426+
// don't set an endpoint if none is configured, instead let the SDK figure it out.
427+
return null;
428+
}
429+
430+
if (!endpoint.contains("://")) {
431+
endpoint = String.format("%s://%s", protocol, endpoint);
432+
}
433+
434+
try {
435+
return new URI(endpoint);
436+
} catch (URISyntaxException e) {
437+
throw new IllegalArgumentException(e);
438+
}
424439
}
425440

426441
/**

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,19 @@ public void testCentralEndpointAndNullRegionFipsWithCRUD() throws Throwable {
516516
|| bucketLocation.startsWith(CA_REGION_PREFIX)
517517
|| bucketLocation.startsWith(US_DUAL_STACK_PREFIX));
518518

519-
final Configuration conf = getConfiguration();
519+
final Configuration conf = getFileSystem().getConf();
520520
final Configuration newConf = new Configuration(conf);
521521

522522
removeBaseAndBucketOverrides(
523523
newConf,
524524
ENDPOINT,
525525
AWS_REGION,
526-
FIPS_ENDPOINT);
526+
FIPS_ENDPOINT,
527+
PATH_STYLE_ACCESS);
527528

528529
newConf.set(ENDPOINT, CENTRAL_ENDPOINT);
529530
newConf.setBoolean(FIPS_ENDPOINT, true);
531+
newConf.setBoolean(PATH_STYLE_ACCESS, false);
530532

531533
newFS = new S3AFileSystem();
532534
newFS.initialize(getFileSystem().getUri(), newConf);

0 commit comments

Comments
 (0)