Skip to content

Commit 2d2e736

Browse files
authored
Merge branch 'apache:trunk' into HADOOP-19298
2 parents 98f43d6 + 4e6432a commit 2d2e736

File tree

18 files changed

+236
-47
lines changed

18 files changed

+236
-47
lines changed

hadoop-client-modules/hadoop-client-runtime/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@
229229
<exclude>jnamed*</exclude>
230230
<exclude>lookup*</exclude>
231231
<exclude>update*</exclude>
232-
<exclude>META-INF/versions/21/*</exclude>
233-
<exclude>META-INF/versions/21/**/*</exclude>
232+
<exclude>META-INF/versions/18/*</exclude>
233+
<exclude>META-INF/versions/18/**/*</exclude>
234+
<exclude>META-INF/services/java.net.spi.InetAddressResolverProvider</exclude>
234235
</excludes>
235236
</filter>
236237
<filter>
@@ -245,7 +246,7 @@
245246
<excludes>
246247
<exclude>META-INF/versions/9/module-info.class</exclude>
247248
<exclude>META-INF/versions/11/module-info.class</exclude>
248-
<exclude>META-INF/versions/21/module-info.class</exclude>
249+
<exclude>META-INF/versions/18/module-info.class</exclude>
249250
</excludes>
250251
</filter>
251252

hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,19 @@ function hadoop_finalize_hadoop_opts
15691569
hadoop_add_param HADOOP_OPTS hadoop.security.logger "-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER}"
15701570
}
15711571

1572+
## @description Finish configuring JPMS that enforced for JDK 17 and higher
1573+
## @description prior to executing Java
1574+
## @audience private
1575+
## @stability evolving
1576+
## @replaceable yes
1577+
function hadoop_finalize_jpms_opts
1578+
{
1579+
hadoop_add_param HADOOP_OPTS IgnoreUnrecognizedVMOptions "-XX:+IgnoreUnrecognizedVMOptions"
1580+
hadoop_add_param HADOOP_OPTS open.java.util.zip "--add-opens=java.base/java.util.zip=ALL-UNNAMED"
1581+
hadoop_add_param HADOOP_OPTS open.sun.security.util "--add-opens=java.base/sun.security.util=ALL-UNNAMED"
1582+
hadoop_add_param HADOOP_OPTS open.sun.security.x509 "--add-opens=java.base/sun.security.x509=ALL-UNNAMED"
1583+
}
1584+
15721585
## @description Finish Java classpath prior to execution
15731586
## @audience private
15741587
## @stability evolving
@@ -1597,6 +1610,7 @@ function hadoop_finalize
15971610
hadoop_finalize_libpaths
15981611
hadoop_finalize_hadoop_heap
15991612
hadoop_finalize_hadoop_opts
1613+
hadoop_finalize_jpms_opts
16001614

16011615
hadoop_translate_cygwin_path HADOOP_HOME
16021616
hadoop_translate_cygwin_path HADOOP_CONF_DIR

hadoop-project/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@
167167
<enforced.java.version>[${javac.version},)</enforced.java.version>
168168
<enforced.maven.version>[3.3.0,)</enforced.maven.version>
169169

170+
<extraJavaTestArgs>
171+
-XX:+IgnoreUnrecognizedVMOptions
172+
--add-opens=java.base/java.util.zip=ALL-UNNAMED
173+
--add-opens=java.base/sun.security.util=ALL-UNNAMED
174+
--add-opens=java.base/sun.security.x509=ALL-UNNAMED
175+
</extraJavaTestArgs>
170176
<!-- Plugin versions and config -->
171-
<maven-surefire-plugin.argLine>-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError</maven-surefire-plugin.argLine>
177+
<maven-surefire-plugin.argLine>-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError ${extraJavaTestArgs}</maven-surefire-plugin.argLine>
172178
<maven-surefire-plugin.version>3.0.0-M1</maven-surefire-plugin.version>
173179
<maven-surefire-report-plugin.version>${maven-surefire-plugin.version}</maven-surefire-report-plugin.version>
174180
<maven-failsafe-plugin.version>${maven-surefire-plugin.version}</maven-failsafe-plugin.version>
@@ -178,7 +184,7 @@
178184
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
179185
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
180186
<maven-jar-plugin.version>2.5</maven-jar-plugin.version>
181-
<maven-war-plugin.version>3.1.0</maven-war-plugin.version>
187+
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
182188
<maven-source-plugin.version>2.3</maven-source-plugin.version>
183189
<maven-pdf-plugin.version>1.2</maven-pdf-plugin.version>
184190
<maven-remote-resources-plugin.version>1.5</maven-remote-resources-plugin.version>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,19 @@ private Constants() {
13721372
*/
13731373
public static final String XA_HEADER_PREFIX = "header.";
13741374

1375+
/**
1376+
* S3 cross region access enabled ?
1377+
* Value: {@value}.
1378+
*/
1379+
1380+
public static final String AWS_S3_CROSS_REGION_ACCESS_ENABLED =
1381+
"fs.s3a.cross.region.access.enabled";
1382+
/**
1383+
* Default value for S3 cross region access enabled: {@value}.
1384+
*/
1385+
public static final boolean AWS_S3_CROSS_REGION_ACCESS_ENABLED_DEFAULT = true;
1386+
1387+
13751388
/**
13761389
* AWS S3 region for the bucket. When set bypasses the construction of
13771390
* region through endpoint url.

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
import static org.apache.hadoop.fs.s3a.Constants.AWS_REGION;
5959
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_ACCESS_GRANTS_ENABLED;
6060
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_ACCESS_GRANTS_FALLBACK_TO_IAM_ENABLED;
61+
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_CROSS_REGION_ACCESS_ENABLED;
62+
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_CROSS_REGION_ACCESS_ENABLED_DEFAULT;
6163
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_DEFAULT_REGION;
6264
import static org.apache.hadoop.fs.s3a.Constants.CENTRAL_ENDPOINT;
6365
import static org.apache.hadoop.fs.s3a.Constants.FIPS_ENDPOINT;
@@ -330,7 +332,6 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void
330332
builder.endpointOverride(endpoint);
331333
LOG.debug("Setting endpoint to {}", endpoint);
332334
} else {
333-
builder.crossRegionAccessEnabled(true);
334335
origin = "central endpoint with cross region access";
335336
LOG.debug("Enabling cross region access for endpoint {}",
336337
endpointStr);
@@ -343,7 +344,6 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void
343344
// no region is configured, and none could be determined from the endpoint.
344345
// Use US_EAST_2 as default.
345346
region = Region.of(AWS_S3_DEFAULT_REGION);
346-
builder.crossRegionAccessEnabled(true);
347347
builder.region(region);
348348
origin = "cross region access fallback";
349349
} else if (configuredRegion.isEmpty()) {
@@ -354,8 +354,14 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void
354354
LOG.debug(SDK_REGION_CHAIN_IN_USE);
355355
origin = "SDK region chain";
356356
}
357-
358-
LOG.debug("Setting region to {} from {}", region, origin);
357+
boolean isCrossRegionAccessEnabled = conf.getBoolean(AWS_S3_CROSS_REGION_ACCESS_ENABLED,
358+
AWS_S3_CROSS_REGION_ACCESS_ENABLED_DEFAULT);
359+
// s3 cross region access
360+
if (isCrossRegionAccessEnabled) {
361+
builder.crossRegionAccessEnabled(true);
362+
}
363+
LOG.debug("Setting region to {} from {} with cross region access {}",
364+
region, origin, isCrossRegionAccessEnabled);
359365
}
360366

361367
/**

hadoop-tools/hadoop-aws/src/site/markdown/tools/hadoop-aws/connecting.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ There are multiple ways to connect to an S3 bucket
4848

4949
The S3A connector supports all these; S3 Endpoints are the primary mechanism used -either explicitly declared or automatically determined from the declared region of the bucket.
5050

51+
The S3A connector supports S3 cross region access via AWS SDK which is enabled by default. This allows users to access S3 buckets in a different region than the one defined in the S3 endpoint/region configuration, as long as they are within the same AWS partition. However, S3 cross-region access can be disabled by:
52+
```xml
53+
<property>
54+
<name>fs.s3a.cross.region.access.enabled</name>
55+
<value>false</value>
56+
<description>S3 cross region access</description>
57+
</property>
58+
```
59+
60+
5161
Not supported:
5262
* AWS [Snowball](https://aws.amazon.com/snowball/).
5363

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ public void testCustomUserAgent() throws Exception {
439439
@Test
440440
public void testRequestTimeout() throws Exception {
441441
conf = new Configuration();
442+
skipIfCrossRegionClient(conf);
442443
// remove the safety check on minimum durations.
443444
AWSClientConfig.setMinimumOperationDuration(Duration.ZERO);
444445
try {
@@ -632,8 +633,8 @@ public static boolean isSTSSignerCalled() {
632633
*/
633634
private static void skipIfCrossRegionClient(
634635
Configuration configuration) {
635-
if (configuration.get(ENDPOINT, null) == null
636-
&& configuration.get(AWS_REGION, null) == null) {
636+
if (configuration.getBoolean(AWS_S3_CROSS_REGION_ACCESS_ENABLED,
637+
AWS_S3_CROSS_REGION_ACCESS_ENABLED_DEFAULT)) {
637638
skip("Skipping test as cross region client is in use ");
638639
}
639640
}

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
import org.apache.hadoop.fs.s3a.statistics.impl.EmptyS3AStatisticsContext;
4545
import org.apache.hadoop.fs.s3a.test.PublicDatasetTestUtils;
4646

47+
import static org.apache.hadoop.fs.contract.ContractTestUtils.skip;
4748
import static org.apache.hadoop.fs.s3a.Constants.ALLOW_REQUESTER_PAYS;
4849
import static org.apache.hadoop.fs.s3a.Constants.AWS_REGION;
50+
import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_CROSS_REGION_ACCESS_ENABLED;
4951
import static org.apache.hadoop.fs.s3a.Constants.CENTRAL_ENDPOINT;
5052
import static org.apache.hadoop.fs.s3a.Constants.ENDPOINT;
5153
import static org.apache.hadoop.fs.s3a.Constants.FIPS_ENDPOINT;
@@ -71,6 +73,8 @@ public class ITestS3AEndpointRegion extends AbstractS3ATestBase {
7173

7274
private static final String US_WEST_2 = "us-west-2";
7375

76+
private static final String SA_EAST_1 = "sa-east-1";
77+
7478
private static final String EU_WEST_2 = "eu-west-2";
7579

7680
private static final String CN_NORTHWEST_1 = "cn-northwest-1";
@@ -346,6 +350,41 @@ public void testCentralEndpointAndDifferentRegionThanBucket() throws Throwable {
346350
assertRequesterPaysFileExistence(newConf);
347351
}
348352

353+
@Test
354+
public void testWithOutCrossRegionAccess() throws Exception {
355+
describe("Verify cross region access fails when disabled");
356+
// skip the test if the region is sa-east-1
357+
skipCrossRegionTest();
358+
final Configuration newConf = new Configuration(getConfiguration());
359+
// disable cross region access
360+
newConf.setBoolean(AWS_S3_CROSS_REGION_ACCESS_ENABLED, false);
361+
newConf.set(AWS_REGION, SA_EAST_1);
362+
try (S3AFileSystem fs = new S3AFileSystem()) {
363+
fs.initialize(getFileSystem().getUri(), newConf);
364+
intercept(AWSRedirectException.class,
365+
"does not match the AWS region containing the bucket",
366+
() -> fs.exists(getFileSystem().getWorkingDirectory()));
367+
}
368+
}
369+
370+
@Test
371+
public void testWithCrossRegionAccess() throws Exception {
372+
describe("Verify cross region access succeed when enabled");
373+
// skip the test if the region is sa-east-1
374+
skipCrossRegionTest();
375+
final Configuration newConf = new Configuration(getConfiguration());
376+
removeBaseAndBucketOverrides(newConf,
377+
AWS_S3_CROSS_REGION_ACCESS_ENABLED,
378+
AWS_REGION);
379+
// enable cross region access
380+
newConf.setBoolean(AWS_S3_CROSS_REGION_ACCESS_ENABLED, true);
381+
newConf.set(AWS_REGION, SA_EAST_1);
382+
try (S3AFileSystem fs = new S3AFileSystem()) {
383+
fs.initialize(getFileSystem().getUri(), newConf);
384+
fs.exists(getFileSystem().getWorkingDirectory());
385+
}
386+
}
387+
349388
@Test
350389
public void testCentralEndpointAndSameRegionAsBucket() throws Throwable {
351390
describe("Access public bucket using central endpoint and region "
@@ -478,6 +517,16 @@ public void testCentralEndpointAndNullRegionFipsWithCRUD() throws Throwable {
478517
assertOpsUsingNewFs();
479518
}
480519

520+
/**
521+
* Skip the test if the region is null or sa-east-1.
522+
*/
523+
private void skipCrossRegionTest() throws IOException {
524+
String region = getFileSystem().getS3AInternals().getBucketMetadata().bucketRegion();
525+
if (region == null || SA_EAST_1.equals(region)) {
526+
skip("Skipping test since region is null or it is set to sa-east-1");
527+
}
528+
}
529+
481530
private void assertOpsUsingNewFs() throws IOException {
482531
final String file = getMethodName();
483532
final Path basePath = methodPath();

hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,4 @@
726726
<Package name="org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.placement.schema" />
727727
</Match>
728728

729-
<!-- The ServiceScheduler#createConfigFileCache method uses the `load` method,
730-
which is not allowed to return null; we can ignore it here. -->
731-
<Match>
732-
<Class name="org.apache.hadoop.yarn.service.ServiceScheduler"/>
733-
<Method name="$1.load(ConfigFile)" />
734-
<Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
735-
</Match>
736-
737729
</FindBugsFilter>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/dev-support/findbugs-exclude.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@
5656
</Or>
5757
<Bug pattern="SE_BAD_FIELD" />
5858
</Match>
59+
<Match>
60+
<Class name="org.apache.hadoop.yarn.service.ServiceScheduler$1"/>
61+
<Method name="load"/>
62+
<Bug code="NP" pattern="NP_NONNULL_RETURN_VIOLATION"/>
63+
</Match>
5964
</FindBugsFilter>

0 commit comments

Comments
 (0)