You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JTaky (via GitHub)" <gi...@apache.org> on 2024/03/25 16:38:41 UTC

[PR] [FLINK-33376][coordination] Extend ZooKeeper Curator configurations [flink]

JTaky opened a new pull request, #24563:
URL: https://github.com/apache/flink/pull/24563

   <!--
   *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
   
   This PR introduces new configuration options for Flink and Curator configurations, such as:
   * authorization - option which expose to allow additional AuthInfo records as part of the connect
   * maxCloseWaitMs - Ability that would enable the user to adjust to different network speeds.
   * simulatedSessionExpirationPercent - Additional checking for Session expiration above what is provided by ZooKeeper.
   
   Such configuration has been proposed as part of [FLIP-402](https://cwiki.apache.org/confluence/display/FLINK/FLIP-402%3A+Extend+ZooKeeper+Curator+configurations).
   
   ## Brief change log
   
   * Adds a new configurations into HighAvailabilityOptions
   * In case if newly added configs are configured, they are invoking appropriate builder method during Curator connection creation
   * If no configuration are passed, no new configurations are being applied
   
   ## Verifying this change
   
   This change is a trivial rework / code cleanup without any test coverage.
   The code path is executed in several test scenarios, e.g. ZooKeeperLeaderElectionITCase#testJobExecutionOnClusterWithLeaderChange.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? docs / JavaDocs
   


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,38 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(
+                                                                    ConfigConstants
+                                                                            .DEFAULT_CHARSET)))
+                            .collect(Collectors.toList());
+            curatorFrameworkBuilder.authorization(authInfos);
+        }
+
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)) {
+            curatorFrameworkBuilder.maxCloseWaitMs(
+                    (int)
+                            configuration
+                                    .get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)
+                                    .toMillis());

Review Comment:
   I am hesitant to throw an Exception here, but probably it can help somebody who will put wrong duration value, e.g. days? (MaxInteger in ms is more than 500 hours)
   ```            
   if (maxCloseWait < Integer.MIN_VALUE || maxCloseWait > Integer.MAX_VALUE) {
                   throw new IllegalConfigurationException(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT.key() + " in ms is not an integer - " + maxCloseWait);
               }```
   
   As an alternative we could imagine to put a WARN and silently limit the value to the MaxInteger. While it is always a bad practice to make something implicit.



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   @flinkbot run azure


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,38 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(
+                                                                    ConfigConstants
+                                                                            .DEFAULT_CHARSET)))
+                            .collect(Collectors.toList());
+            curatorFrameworkBuilder.authorization(authInfos);
+        }
+
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)) {
+            curatorFrameworkBuilder.maxCloseWaitMs(
+                    (int)
+                            configuration
+                                    .get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)
+                                    .toMillis());

Review Comment:
   You have a point there. It appears to be a quite nitty. But on the other hand, it's also quite unlikely that a user would set such a timeout. Therefore, an exception wouldn't hurt. :shrug: 



##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,38 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(
+                                                                    ConfigConstants
+                                                                            .DEFAULT_CHARSET)))
+                            .collect(Collectors.toList());
+            curatorFrameworkBuilder.authorization(authInfos);
+        }
+
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT)) {
+            long maxCloseWait = configuration.get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT).toMillis();
+            if (maxCloseWait < Integer.MIN_VALUE || maxCloseWait > Integer.MAX_VALUE) {
+                throw new IllegalConfigurationException(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT.key() + " in ms is not an integer - " + maxCloseWait);

Review Comment:
   ```suggestion
                   if (maxCloseWait < 0 || maxCloseWait > Integer.MAX_VALUE) {
                   throw new IllegalConfigurationException(
                           "The value (%d ms) is out-of-range for %s. The milliseconds timeout is expected to be between 0 and %d ms.",
                           maxCloseWait,
                           HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT.key(),
                           Integer.MAX_VALUE);
               }
   ```
   nit: since tthere is a constructor for formatted strings.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,38 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(
+                                                                    ConfigConstants
+                                                                            .DEFAULT_CHARSET)))
+                            .collect(Collectors.toList());
+            curatorFrameworkBuilder.authorization(authInfos);
+        }
+
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT)) {
+            long maxCloseWait = configuration.get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT).toMillis();
+            if (maxCloseWait < Integer.MIN_VALUE || maxCloseWait > Integer.MAX_VALUE) {

Review Comment:
   ```suggestion
               if (maxCloseWait < 0 || maxCloseWait > Integer.MAX_VALUE) {
   ```
   I guess, we should stay in the positive range for the timeout, shouldn't we?



##########
docs/layouts/shortcodes/generated/high_availability_configuration.html:
##########


Review Comment:
   The docs are not regenerated.



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble."

Review Comment:
   ```suggestion
                                                       + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble."
   ```
   nit



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encoding"
+                                                    + "If not set the default configuration for a Curator would be applied.")
+                                    .build());
+
+    public static final ConfigOption<Integer> ZOOKEEPER_MAX_CLOSE_WAIT_MS =
+            key("high-availability.zookeeper.client.max-close-wait-ms")
+                    .intType()

Review Comment:
   ```suggestion
       public static final ConfigOption<Duration> ZOOKEEPER_MAX_CLOSE_WAIT_TIMEOUT =
               key("high-availability.zookeeper.client.max-close-wait")
                       .durationType()
   ```
   What about using `Duration` here? That makes it easier for the user to define his/her own time unit.



##########
docs/layouts/shortcodes/generated/high_availability_configuration.html:
##########
@@ -68,6 +80,12 @@
             <td>Integer</td>
             <td>Defines the session timeout for the ZooKeeper session in ms.</td>
         </tr>
+        <tr>
+            <td><h5>high-availability.zookeeper.client.simulated-session-expiration-percent</h5></td>
+            <td style="word-wrap: break-word;">(none)</td>
+            <td>Integer</td>
+            <td>Curator has the option of attempting to monitor session expiration above what is provided by ZooKeeper. The percentage set by this method determines how and if Curator will check for session expiration. If it is set to 0, Curator does not do any additional checking for session expiration. If a positive number is set, Curator will check for session expiration as follows: when ZooKeeper sends a Disconnect event, Curator will start a timer. If re-connection is not achieved before the elapsed time exceeds the negotiated session time multiplied by the session expiration percent, Curator will simulate a session expiration. Due to timing/network issues, it is not possible for a client to match the server's session timeout with complete accuracy. Thus, the need for a session expiration percentage.If not set the default configuration for a Curator would be used.</td>

Review Comment:
   I'm wondering whether we could use a link to the curator documentation rather than having the curator documentation being copied into the Flink configuration. ...just to reduce maintenance on our side. WDYT? :thinking: 



##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,33 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(StandardCharsets.UTF_8)))

Review Comment:
   ```suggestion
                                                               .getBytes(ConfigConstants.DEFAULT_CHARSET)))
   ```
   What about relying on Flink's default charset? That would enable us to make the corresponding documentation more generic.



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encoding"

Review Comment:
   ```suggestion
                                                 + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with %s encoding"
                                                       + "If not set the default configuration for a Curator would be applied.",
                                               text(ConfigConstants.DEFAULT_CHARSET.displayName()))
   ```



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "

Review Comment:
   ```suggestion
                                                       + "In certain cases ZooKeeper requires additional Authorization information. "
   ```



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encoding"

Review Comment:
   Maybe shortening the substrings might be useful as well. Not everyone has an ultra weight screen. :-)



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   @flinkbot run azure


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,33 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(StandardCharsets.UTF_8)))

Review Comment:
   ```suggestion
                                                               .getBytes(ConfigConstants.DEFAULT_CHARSET)))
   ```
   What about relying on Flink's default charset? That would enable us to make the [corresponding documentation more generic](https://github.com/apache/flink/pull/24563#discussion_r1539271642).



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
docs/layouts/shortcodes/generated/high_availability_configuration.html:
##########
@@ -68,6 +80,12 @@
             <td>Integer</td>
             <td>Defines the session timeout for the ZooKeeper session in ms.</td>
         </tr>
+        <tr>
+            <td><h5>high-availability.zookeeper.client.simulated-session-expiration-percent</h5></td>
+            <td style="word-wrap: break-word;">(none)</td>
+            <td>Integer</td>
+            <td>Curator has the option of attempting to monitor session expiration above what is provided by ZooKeeper. The percentage set by this method determines how and if Curator will check for session expiration. If it is set to 0, Curator does not do any additional checking for session expiration. If a positive number is set, Curator will check for session expiration as follows: when ZooKeeper sends a Disconnect event, Curator will start a timer. If re-connection is not achieved before the elapsed time exceeds the negotiated session time multiplied by the session expiration percent, Curator will simulate a session expiration. Due to timing/network issues, it is not possible for a client to match the server's session timeout with complete accuracy. Thus, the need for a session expiration percentage.If not set the default configuration for a Curator would be used.</td>

Review Comment:
   Thanks for the advice. 



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   Thanks @XComp for the review and sorry for more back and force than should be.


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   no worries :-)


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +225,50 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + "In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed "
+                                                    + "into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() "
+                                                    + "will be initially converted to a byte[] using the String#getBytes() method with %s encoding"
+                                                    + "If not set the default configuration for a Curator would be applied.",
+                                            text(ConfigConstants.DEFAULT_CHARSET.displayName()))
+                                    .build());
+
+    public static final ConfigOption<Duration> ZOOKEEPER_MAX_CLOSE_WAIT_MS =
+            key("high-availability.zookeeper.client.max-close-wait-ms")
+                    .durationType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Defines the time Curator should wait during close to join background threads. "
+                                                    + "If not set the default configuration for a Curator would be applied.")
+                                    .build());
+
+    public static final ConfigOption<Integer> ZOOKEEPER_SIMULATED_SESSION_EXP_PERCENT =
+            key("high-availability.zookeeper.client.simulated-session-expiration-percent")
+                    .intType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "The percentage set by this method determines how and if Curator will check for session expiration. "
+                                                    + "See Curator documentation for %s property for more information",

Review Comment:
   ```suggestion
                                                       + "See Curator documentation for %s property for more information.",
   ```



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +225,50 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + "In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed "
+                                                    + "into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() "
+                                                    + "will be initially converted to a byte[] using the String#getBytes() method with %s encoding"
+                                                    + "If not set the default configuration for a Curator would be applied.",
+                                            text(ConfigConstants.DEFAULT_CHARSET.displayName()))
+                                    .build());
+
+    public static final ConfigOption<Duration> ZOOKEEPER_MAX_CLOSE_WAIT_MS =
+            key("high-availability.zookeeper.client.max-close-wait-ms")

Review Comment:
   ```suggestion
       public static final ConfigOption<Duration> ZOOKEEPER_MAX_CLOSE_WAIT =
               key("high-availability.zookeeper.client.max-close-wait")
   ```
   The `ms" suffix is not needed anymore because we're relying on `Duration`.



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +225,50 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + "In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble."

Review Comment:
   ```suggestion
                                                       + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble. "
   ```



##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +225,50 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + "In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent accidentally connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed "
+                                                    + "into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() "
+                                                    + "will be initially converted to a byte[] using the String#getBytes() method with %s encoding"

Review Comment:
   ```suggestion
                                                       + "will be initially converted to a byte[] using the String#getBytes() method with %s encoding. "
   ```



##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java:
##########
@@ -246,6 +249,38 @@ public static CuratorFrameworkWithUnhandledErrorListener startCuratorFramework(
                         .ensembleTracker(ensembleTracking)
                         .aclProvider(aclProvider);
 
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION)) {
+            Map<String, String> authMap =
+                    configuration.get(HighAvailabilityOptions.ZOOKEEPER_CLIENT_AUTHORIZATION);
+            List<AuthInfo> authInfos =
+                    authMap.entrySet().stream()
+                            .map(
+                                    entry ->
+                                            new AuthInfo(
+                                                    entry.getKey(),
+                                                    entry.getValue()
+                                                            .getBytes(
+                                                                    ConfigConstants
+                                                                            .DEFAULT_CHARSET)))
+                            .collect(Collectors.toList());
+            curatorFrameworkBuilder.authorization(authInfos);
+        }
+
+        if (configuration.contains(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)) {
+            curatorFrameworkBuilder.maxCloseWaitMs(
+                    (int)
+                            configuration
+                                    .get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS)
+                                    .toMillis());

Review Comment:
   ```suggestion
               final Duration maxCloseWaitDuration =
                       configuration.get(HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS);
               final long maxCloseWaitInMillis = maxCloseWaitDuration.toMillis();
               Preconditions.checkArgument(
                       maxCloseWaitInMillis <= Integer.MAX_VALUE,
                       "The passed value of {} for {} exceeded to valid range of {}ms.",
                       maxCloseWaitDuration,
                       HighAvailabilityOptions.ZOOKEEPER_MAX_CLOSE_WAIT_MS.key(),
                       Duration.ofMillis(Integer.MAX_VALUE));
               curatorFrameworkBuilder.maxCloseWaitMs((int) maxCloseWaitInMillis);
   ```
   Can we add another safety net for the cast to fail early if (by any chance) an unexpected value is used?



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> CLIENT_AUTHORIZATION =

Review Comment:
   I would rename this one
   ```suggestion
       public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
   ```



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
flink-core/src/main/java/org/apache/flink/configuration/HighAvailabilityOptions.java:
##########
@@ -220,6 +222,52 @@ public class HighAvailabilityOptions {
                                                     + "with unresolvable hostnames.")
                                     .build());
 
+    public static final ConfigOption<Map<String, String>> ZOOKEEPER_CLIENT_AUTHORIZATION =
+            key("high-availability.zookeeper.client.authorization")
+                    .mapType()
+                    .noDefaultValue()
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Add connection authorization Subsequent calls to this method overwrite the prior calls. "
+                                                    + " In certain cases ZooKeeper requires additional Authorization information. "
+                                                    + "For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble."
+                                                    + "Each entry of type Map.Entry<String, String> will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). "
+                                                    + "The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encoding"
+                                                    + "If not set the default configuration for a Curator would be applied.")
+                                    .build());
+
+    public static final ConfigOption<Integer> ZOOKEEPER_MAX_CLOSE_WAIT_MS =
+            key("high-availability.zookeeper.client.max-close-wait-ms")
+                    .intType()

Review Comment:
   Thanks, will apply the duration type and add the appropriate conversion (to ms and to int) during the utilisation



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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


##########
docs/layouts/shortcodes/generated/high_availability_configuration.html:
##########
@@ -68,6 +80,12 @@
             <td>Integer</td>
             <td>Defines the session timeout for the ZooKeeper session in ms.</td>
         </tr>
+        <tr>
+            <td><h5>high-availability.zookeeper.client.simulated-session-expiration-percent</h5></td>
+            <td style="word-wrap: break-word;">(none)</td>
+            <td>Integer</td>
+            <td>Curator has the option of attempting to monitor session expiration above what is provided by ZooKeeper. The percentage set by this method determines how and if Curator will check for session expiration. If it is set to 0, Curator does not do any additional checking for session expiration. If a positive number is set, Curator will check for session expiration as follows: when ZooKeeper sends a Disconnect event, Curator will start a timer. If re-connection is not achieved before the elapsed time exceeds the negotiated session time multiplied by the session expiration percent, Curator will simulate a session expiration. Due to timing/network issues, it is not possible for a client to match the server's session timeout with complete accuracy. Thus, the need for a session expiration percentage.If not set the default configuration for a Curator would be used.</td>

Review Comment:
   ```suggestion
               <td>Curator has the option of attempting to monitor session expiration above what is provided by ZooKeeper. The percentage set by this method determines how and if Curator will check for session expiration. If it is set to 0, Curator does not do any additional checking for session expiration. If a positive number is set, Curator will check for session expiration as follows: when ZooKeeper sends a Disconnect event, Curator will start a timer. If re-connection is not achieved before the elapsed time exceeds the negotiated session time multiplied by the session expiration percent, Curator will simulate a session expiration. Due to timing/network issues, it is not possible for a client to match the server's session timeout with complete accuracy. Thus, the need for a session expiration percentage. If not set the default configuration for a Curator would be used.</td>
   ```



##########
docs/layouts/shortcodes/generated/high_availability_configuration.html:
##########
@@ -38,6 +38,12 @@
             <td>String</td>
             <td>Defines the ACL (open|creator) to be configured on ZK node. The configuration value can be set to “creator” if the ZooKeeper server configuration has the “authProvider” property mapped to use SASLAuthenticationProvider and the cluster is configured to run in secure mode (Kerberos).</td>
         </tr>
+        <tr>
+            <td><h5>high-availability.zookeeper.client.authorization</h5></td>
+            <td style="word-wrap: break-word;">(none)</td>
+            <td>Map</td>
+            <td>Add connection authorization Subsequent calls to this method overwrite the prior calls.  In certain cases ZooKeeper requires additional Authorization information. For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble.Each entry of type Map.Entry&lt;String, String&gt; will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encodingIf not set the default configuration for a Curator would be applied.</td>

Review Comment:
   ```suggestion
               <td>Add connection authorization Subsequent calls to this method overwrite the prior calls. In certain cases ZooKeeper requires additional Authorization information. For example list of valid names for ensemble in order to prevent the accidental connecting to a wrong ensemble. Each entry of type Map.Entry&lt;String, String&gt; will be transformed into an AuthInfo object with the constructor AuthInfo(String, byte[]). The field entry.key() will serve as the String scheme value, while the field entry.getValue() will be initially converted to a byte[] using the String#getBytes() method with UTF8 encoding. If not set the default configuration for a Curator would be applied.</td>
   ```



-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   @flinkbot run azure


-- 
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-33376][coordination] Extend ZooKeeper Curator configurations [flink]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1bd4705526fd452c4e793bef4e9bfa2557641d7e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1bd4705526fd452c4e793bef4e9bfa2557641d7e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1bd4705526fd452c4e793bef4e9bfa2557641d7e 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