Skip to content

YARN-11796. Accept extra JDK 17 options in tests #7512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
Expand Down Expand Up @@ -311,6 +312,13 @@ public void testStartLocalizer() throws IOException {
.build());

List<String> result=readMockParams();

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(result.remove("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(result.remove("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAPREDUCE-7456 defines

  private static final String ADDITIONAL_JDK17_PLUS_OPTIONS =
       "--add-opens=java.base/java.lang=ALL-UNNAMED " +
       "--add-exports=java.base/sun.net.dns=ALL-UNNAMED " +
       "--add-exports=java.base/sun.net.util=ALL-UNNAMED";

Why should only the last two be removed?

BTW, could you please leave a few comments that at least mention MAPREDUCE-7456 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pan3793 .

JDK17 options are defined at several locations.
Other than the one you mentioned, they are also defined in org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer which only adds
these two, and apparently these tests trigger that one.

If I added all three, the tests would fail, as --add-opens=java.base/java.lang=ALL-UNNAMED is never added for those test cases.

This also bothers me, I have opened HADOOP-19505 earlier to track this. (Though I have no immediate plans to work on that)

Copy link
Contributor Author

@stoty stoty Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for comments, most tests in TestContainerLocalizer already have similar ifs for JDK17 (I guess these were just added later, and never tested with JDK17).
Would you like me to add comments to those as well ?

Copy link
Member

@pan3793 pan3793 Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to add comments to those as well ?

Yes, please do that, I think the brief comments should help future explorers easy to understand the test code for this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

assertThat(result).hasSize(26);
assertThat(result.get(0)).isEqualTo(YarnConfiguration.
DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ public void testDefaultJavaOptionsWhenExtraJDK17OptionsAreConfigured() throws Ex
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(javaOpts.contains("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(javaOpts.contains("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
Expand All @@ -733,6 +734,7 @@ public void testDefaultJavaOptionsWhenExtraJDK17OptionsAreNotConfigured() throws
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertFalse(javaOpts.contains("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertFalse(javaOpts.contains("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
Expand All @@ -751,6 +753,11 @@ public void testAdminOptionsPrecedeUserDefinedJavaOptions() throws Exception {
" userOption1 userOption2");
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
assertEquals(4, javaOpts.size());
assertTrue(javaOpts.get(0).equals("adminOption1"));
assertTrue(javaOpts.get(1).equals("adminOption2"));
Expand All @@ -768,6 +775,11 @@ public void testAdminOptionsPrecedeDefaultUserOptions() throws Exception {
"adminOption1 adminOption2");
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
assertEquals(3, javaOpts.size());
assertTrue(javaOpts.get(0).equals("adminOption1"));
assertTrue(javaOpts.get(1).equals("adminOption2"));
Expand All @@ -784,6 +796,11 @@ public void testUserOptionsWhenAdminOptionsAreNotDefined() throws Exception {
"userOption1 userOption2");
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
assertEquals(2, javaOpts.size());
assertTrue(javaOpts.get(0).equals("userOption1"));
assertTrue(javaOpts.get(1).equals("userOption2"));
Expand All @@ -797,6 +814,11 @@ public void testJavaOptionsWithoutDefinedAdminOrUserOptions() throws Exception {
Configuration conf = new Configuration();
List<String> javaOpts = localizer.getJavaOpts(conf);

if (Shell.isJavaVersionAtLeast(17)) {
// Added by ContainerLocalizer for JDK17+ (MAPREDUCE-7456)
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.dns=ALL-UNNAMED"));
assertTrue(javaOpts.remove("--add-exports=java.base/sun.net.util=ALL-UNNAMED"));
}
assertEquals(1, javaOpts.size());
assertTrue(javaOpts.get(0).equals("-Xmx256m"));
}
Expand Down