You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "X-czh (via GitHub)" <gi...@apache.org> on 2024/01/15 17:09:06 UTC

[PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

X-czh opened a new pull request, #24098:
URL: https://github.com/apache/flink/pull/24098

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Add config options for administrator JVM options.
   
   ## Brief change log
   
   1. Added three config options: `env.java.default-opts.all`, `env.java.default-opts.jobmanager` `env.java.default-opts.taskmanager` that prepends to the corresponding non-default options.
   2. For non-YARN envs, directly assemble the JVM opts in shell command.
   3. For YARN env, change BootstrapTools#getTaskManagerShellCommand & YarnClusterDescriptor acccordingly. 
   
   ## Verifying this change
   
   - The non-YARN related change is tested by starting local standalone clusters & K8s clusters and manually verify the JVM opts.
   - The YARN-related change is covered by UT.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no) no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no) no
     - The serializers: (yes / no / don't know) no
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know) no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know) no
     - The S3 file system connector: (yes / no / don't know) no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no) yes
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented) docs
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "X-czh (via GitHub)" <gi...@apache.org>.
X-czh commented on PR #24098:
URL: https://github.com/apache/flink/pull/24098#issuecomment-1893096096

   Hi @huwh @1996fanrui, do you have time to help review this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on PR #24098:
URL: https://github.com/apache/flink/pull/24098#issuecomment-1899825447

   Hi @X-czh , https://github.com/apache/flink/pull/24089 is merged, please go ahead, thanks~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24098:
URL: https://github.com/apache/flink/pull/24098#issuecomment-1892538860

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "ecffb8726b98504c5924367e7fc808c0ceaeb276",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ecffb8726b98504c5924367e7fc808c0ceaeb276",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ecffb8726b98504c5924367e7fc808c0ceaeb276 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui merged PR #24098:
URL: https://github.com/apache/flink/pull/24098


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #24098:
URL: https://github.com/apache/flink/pull/24098#discussion_r1454370046


##########
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java:
##########
@@ -246,6 +244,21 @@ public static String getTaskManagerShellCommand(
         return startCommand;
     }
 
+    public static String generateJvmOptsString(

Review Comment:
   nit: It's better to add a simple unit test for this method before merging.
   
   BTW, you can squash all commits directly after adding the unit test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #24098:
URL: https://github.com/apache/flink/pull/24098#discussion_r1453054820


##########
flink-core/src/main/java/org/apache/flink/configuration/CoreOptions.java:
##########
@@ -282,6 +282,42 @@ public static String[] mergeListsToArray(List<String> base, List<String> append)
                                             "Java options to start the JVM of the Flink SQL Gateway with.")
                                     .build());
 
+    public static final ConfigOption<String> FLINK_DEFAULT_JVM_OPTIONS =
+            ConfigOptions.key("env.java.default-opts.all")
+                    .stringType()
+                    .defaultValue("")
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "A string of default JVM options to prepend to \""
+                                                    + FLINK_JVM_OPTIONS.key()
+                                                    + "\". This is intended to be set by administrators.")

Review Comment:
   ```suggestion
                                               "A string of default JVM options to prepend to %s. This is intended to be set by administrators."
                                               , code(FLINK_JVM_OPTIONS.key()))
   ```
   
   How about it?



##########
flink-dist/src/main/flink-bin/bin/config.sh:
##########
@@ -186,6 +186,9 @@ KEY_ENV_JAVA_OPTS_TM="env.java.opts.taskmanager"
 KEY_ENV_JAVA_OPTS_HS="env.java.opts.historyserver"
 KEY_ENV_JAVA_OPTS_CLI="env.java.opts.client"
 KEY_ENV_JAVA_OPTS_SQL_GATEWAY="env.java.opts.sql-gateway"
+KEY_ENV_JAVA_DEFAULT_OPTS="env.java.default-opts.all"

Review Comment:
   `"env.java.opts.all"` are supported in `pyflink_gateway_server.py`, `"env.java.default-opts.all"` should be considered there as well.



##########
flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterDescriptor.java:
##########
@@ -1834,9 +1834,23 @@ ContainerLaunchContext setupApplicationMasterContainer(
         // ------------------ Prepare Application Master Container  ------------------------------
 
         // respect custom JVM options in the YAML file
-        String javaOpts = flinkConfiguration.getString(CoreOptions.FLINK_JVM_OPTIONS);
-        if (flinkConfiguration.getString(CoreOptions.FLINK_JM_JVM_OPTIONS).length() > 0) {
-            javaOpts += " " + flinkConfiguration.getString(CoreOptions.FLINK_JM_JVM_OPTIONS);
+        String javaOpts = "";
+        String defaultJvmOpts = flinkConfiguration.getString(CoreOptions.FLINK_DEFAULT_JVM_OPTIONS);
+        String jvmOpts = flinkConfiguration.getString(CoreOptions.FLINK_JVM_OPTIONS);
+        String defaultJmJvmOpts =
+                flinkConfiguration.getString(CoreOptions.FLINK_DEFAULT_JM_JVM_OPTIONS);
+        String jmJvmOpts = flinkConfiguration.getString(CoreOptions.FLINK_JM_JVM_OPTIONS);
+        if (!defaultJvmOpts.isEmpty()) {
+            javaOpts += " " + defaultJvmOpts;
+        }
+        if (!jvmOpts.isEmpty()) {
+            javaOpts += " " + jvmOpts;
+        }
+        if (!defaultJmJvmOpts.isEmpty()) {
+            javaOpts += " " + defaultJmJvmOpts;
+        }
+        if (!jmJvmOpts.isEmpty()) {
+            javaOpts += " " + jmJvmOpts;
         }

Review Comment:
   nit: 
   
   Using the `StringBuilder` to build the javaOpts, and we can define a method to avoid repetitive code here.
   
   ```
       private void method(StringBuilder sb, Configuration conf, ConfigOption<String> option) {
           final String javaOpts = conf.get(option);
           if(javaOpts == null || javaOpts.isEmpty()) {
               return;
           }
           sb.append(' ');
           sb.append(javaOpts);
       }
   ```



##########
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java:
##########
@@ -191,9 +191,22 @@ public static String getTaskManagerShellCommand(
         startCommandValues.put(
                 "jvmmem", ProcessMemoryUtils.generateJvmParametersStr(taskExecutorProcessSpec));
 
-        String javaOpts = flinkConfig.getString(CoreOptions.FLINK_JVM_OPTIONS);
-        if (flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS).length() > 0) {
-            javaOpts += " " + flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS);
+        String javaOpts = "";
+        String defaultJvmOpts = flinkConfig.getString(CoreOptions.FLINK_DEFAULT_JVM_OPTIONS);
+        String jvmOpts = flinkConfig.getString(CoreOptions.FLINK_JVM_OPTIONS);
+        String defaultTmJvmOpts = flinkConfig.getString(CoreOptions.FLINK_DEFAULT_TM_JVM_OPTIONS);
+        String tmJvmOpts = flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS);
+        if (!defaultJvmOpts.isEmpty()) {
+            javaOpts += " " + defaultJvmOpts;
+        }
+        if (!jvmOpts.isEmpty()) {
+            javaOpts += " " + jvmOpts;
+        }
+        if (!defaultTmJvmOpts.isEmpty()) {
+            javaOpts += " " + defaultTmJvmOpts;
+        }
+        if (!tmJvmOpts.isEmpty()) {
+            javaOpts += " " + tmJvmOpts;
         }

Review Comment:
   This part is total same with Yarn side, could we extract a common method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "X-czh (via GitHub)" <gi...@apache.org>.
X-czh commented on code in PR #24098:
URL: https://github.com/apache/flink/pull/24098#discussion_r1454864324


##########
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java:
##########
@@ -191,17 +193,13 @@ public static String getTaskManagerShellCommand(
         startCommandValues.put(
                 "jvmmem", ProcessMemoryUtils.generateJvmParametersStr(taskExecutorProcessSpec));
 
-        String javaOpts = flinkConfig.getString(CoreOptions.FLINK_JVM_OPTIONS);
-        if (flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS).length() > 0) {
-            javaOpts += " " + flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS);
-        }
-        javaOpts += " " + IGNORE_UNRECOGNIZED_VM_OPTIONS;
-
-        // krb5.conf file will be available as local resource in JM/TM container
-        if (hasKrb5) {
-            javaOpts += " -Djava.security.krb5.conf=krb5.conf";
-        }
-        startCommandValues.put("jvmopts", javaOpts);
+        List<ConfigOption<String>> jvmOptions =
+                Arrays.asList(
+                        CoreOptions.FLINK_DEFAULT_JVM_OPTIONS,

Review Comment:
   Sure, I'll wait for #24089 first



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "X-czh (via GitHub)" <gi...@apache.org>.
X-czh commented on PR #24098:
URL: https://github.com/apache/flink/pull/24098#issuecomment-1894818999

   Thanks for the quick review @1996fanrui. I've updated the PR accordingly


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-33221][core][config] Add config options for administrator JVM options [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #24098:
URL: https://github.com/apache/flink/pull/24098#discussion_r1454802472


##########
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java:
##########
@@ -191,17 +193,13 @@ public static String getTaskManagerShellCommand(
         startCommandValues.put(
                 "jvmmem", ProcessMemoryUtils.generateJvmParametersStr(taskExecutorProcessSpec));
 
-        String javaOpts = flinkConfig.getString(CoreOptions.FLINK_JVM_OPTIONS);
-        if (flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS).length() > 0) {
-            javaOpts += " " + flinkConfig.getString(CoreOptions.FLINK_TM_JVM_OPTIONS);
-        }
-        javaOpts += " " + IGNORE_UNRECOGNIZED_VM_OPTIONS;
-
-        // krb5.conf file will be available as local resource in JM/TM container
-        if (hasKrb5) {
-            javaOpts += " -Djava.security.krb5.conf=krb5.conf";
-        }
-        startCommandValues.put("jvmopts", javaOpts);
+        List<ConfigOption<String>> jvmOptions =
+                Arrays.asList(
+                        CoreOptions.FLINK_DEFAULT_JVM_OPTIONS,

Review Comment:
   https://github.com/apache/flink/pull/24089 moves the `getTaskManagerShellCommand` from `flink-runtime` module to `flink-yarn` module.
   
   So these 2 PRs have some conflicts. Would you mind merging #24089 first and fix the conflict?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org