You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/09/03 21:56:58 UTC

[GitHub] [druid] dampcake opened a new pull request, #13023: Add interpolation to JsonConfigurator

dampcake opened a new pull request, #13023:
URL: https://github.com/apache/druid/pull/13023

   <!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
   
   <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
   
   Fixes #9617, possibly others.
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for committers:
   https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
   
   ### Description
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the problem? -->
   
   <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: -->
   
   Add a more generic way to use environment variables, system properties, and local files as configuration values. Right now the config needs to either be a `PasswordProvider` or `DynamicConfigProvider` to be able to get the value from an environment variable or other location. While those still make sense for custom implementations (eg: reading values from a secret store) or for task specs, without moving every config to one of those types it makes it hard for an operator to set configuration values from the environment.
   
   This PR uses commons-text to handle the interpolation and only supports a smaller subset of the available interpolations (see: https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html). Upstream they are already looking to disable some of the current defaults as they execute code (javascript) or reach out to external machines (see: https://github.com/apache/commons-text/pull/341) so I started with a much smaller list that should unblock most issues people have.
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
    - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
   -->
   
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `JsonConfigurator`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added documentation for new or modified features or behaviors.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [x] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] pjain1 commented on pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
pjain1 commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1273638902

   @dampcake thanks for the response but I think both options will not work -
   1. Escaping with `$` will prevent the error but in the peon java cmd there will two `$` like `$${HOSTNAME}.hprof` and thus will not be translated to actual value.
   2. Prefixing with `env:` will cause it to be interpreted during MM runtime and not peon runtime, certain values can change in peon case, even hostname can be different depending on task runner.


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] dampcake commented on pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
dampcake commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1273646752

   @pjain1 please note it will be unescaped automatically by the StringSubstitutor if you escape it. So `$${HOSTNAME}` will result in the config being `${HOSTNAME}`. Another option would be to change it to just `$HOSTNAME` as the StringSubstitutor is looking for `${...}`.


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] pjain1 commented on pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
pjain1 commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1272543536

   I think this causes a regression, for example if I add the following option in MM runtime properties files for peons -
   ```
   druid.indexer.runner.javaOptsArray=["-XX:+ExitOnOutOfMemoryError", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/opt/druid/heapdumps/dumps/${HOSTNAME}.hprof"]
   ```
   Then the MM startup will fails with 
   ```
   Caused by: java.lang.IllegalArgumentException: Cannot resolve variable 'SERVICE' (enableSubstitutionInVariables=true).
   	at org.apache.commons.text.StringSubstitutor.substitute(StringSubstitutor.java:1451)
   	at org.apache.commons.text.StringSubstitutor.substitute(StringSubstitutor.java:1308)
   	at org.apache.commons.text.StringSubstitutor.substitute(StringSubstitutor.java:1392)
   	at org.apache.commons.text.StringSubstitutor.substitute(StringSubstitutor.java:1308)
   	at org.apache.commons.text.StringSubstitutor.replace(StringSubstitutor.java:816)
   	at org.apache.druid.guice.JsonConfigurator.configurate(JsonConfigurator.java:104)
   ```
   Any thoughts ?


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add interpolation to JsonConfigurator (druid)

Posted by "xvrl (via GitHub)" <gi...@apache.org>.
xvrl commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1641697131

   @gianm @kfaraz looks like this was missed in the release notes for 25.0.0.
   
   This is actually a breaking change for people already using other mechanism to interpolate some variables.
   
   e.g. when using the Kafka built-in `FileConfigProvider` https://cwiki.apache.org/confluence/display/KAFKA/KIP-297%3A+Externalizing+Secrets+for+Connect+Configurations interpolations are now intercepted by the JsonConfigurator instead of being passed down to the Kafka provider, which breaks existing deployments.


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 merged pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 merged PR #13023:
URL: https://github.com/apache/druid/pull/13023


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] dampcake commented on pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
dampcake commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1273559936

   Yeah it looks like a few configuration options that get used in the ForkingTaskRunner could use environment variables if they are passed as CLI arguments to the new Process. It's a pretty small range of options where this would have worked previously and it's not really consistent across the config system like the new option which will work for all options.
   
   There are two workarounds to get this working with the latest version.
   1. Escaping with `$` which will give the same behavior as before:
   ```
   druid.indexer.runner.javaOptsArray=["-XX:+ExitOnOutOfMemoryError", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/opt/druid/heapdumps/dumps/$${HOSTNAME}.hprof"]
   ```
   2. Prefixing with `env:` which will replace it with the environment variable when the configuration is loaded on the MM:
   ```
   druid.indexer.runner.javaOptsArray=["-XX:+ExitOnOutOfMemoryError", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/opt/druid/heapdumps/dumps/${env:HOSTNAME}.hprof"]
   ```
   
   @kfaraz @abhishekagarwal87 Any thoughts here? Should we exclude ForkingTaskRunner configs or call out is as incompatible?


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 commented on pull request #13023: Add interpolation to JsonConfigurator

Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on PR #13023:
URL: https://github.com/apache/druid/pull/13023#issuecomment-1239003911

   Thank you @dampcake and thanks @kfaraz for the quick review. 


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org