diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java index 0a3267a9fe51d..1048ecf097b29 100644 --- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java +++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java @@ -291,15 +291,25 @@ private , ClientT> void if (endpoint != null) { checkArgument(!fipsEnabled, "%s : %s", ERROR_ENDPOINT_WITH_FIPS, endpoint); - builder.endpointOverride(endpoint); - // No region was configured, try to determine it from the endpoint. - if (region == null) { - region = getS3RegionFromEndpoint(parameters.getEndpoint()); - if (region != null) { - origin = "endpoint"; + if(parameters.getEndpoint().equals(CENTRAL_ENDPOINT)){ + // this will cause some issues, override this and ignore the endpoint setting + // this is to make it similar to cross region access. + region = Region.of(AWS_S3_DEFAULT_REGION); + builder.crossRegionAccessEnabled(true); + builder.region(region); + origin = "cross region access fallback because of global endpoint"; + } + else { + builder.endpointOverride(endpoint); + // No region was configured, try to determine it from the endpoint. + if (region == null) { + region = getS3RegionFromEndpoint(parameters.getEndpoint()); + if (region != null) { + origin = "endpoint"; + } } + LOG.debug("Setting endpoint to {}", endpoint); } - LOG.debug("Setting endpoint to {}", endpoint); } if (region != null) { diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java index 5e6991128b201..917cd9e58a80c 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEndpointRegion.java @@ -146,7 +146,7 @@ public void testCentralEndpoint() throws Throwable { describe("Create a client with the central endpoint"); Configuration conf = getConfiguration(); - S3Client client = createS3Client(conf, CENTRAL_ENDPOINT, null, US_EAST_1, false); + S3Client client = createS3Client(conf, CENTRAL_ENDPOINT, null, US_EAST_2, false); expectInterceptorException(client); } @@ -272,7 +272,7 @@ private final class RegionInterceptor implements ExecutionInterceptor { public void beforeExecution(Context.BeforeExecution context, ExecutionAttributes executionAttributes) { - if (endpoint != null) { + if (endpoint != null && !endpoint.equals(CENTRAL_ENDPOINT)) { Assertions.assertThat( executionAttributes.getAttribute(AwsExecutionAttribute.ENDPOINT_OVERRIDDEN)) .describedAs("Endpoint not overridden").isTrue();