Skip to content

Migrate to dot seperate naming of environment variables #3312

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

epugh
Copy link
Contributor

@epugh epugh commented Apr 7, 2025

https://issues.apache.org/jira/browse/SOLR-XXXXX

Description

Replace legacy property names with the modern default dot notation.

Solution

This started out of some exploration of how to merge the solr.in.sh and solr.in.cmd files, and branched off from there.

I found that if we replaced the legacy variable names (that are mapped in EnvToSyspropMappings.properties) then we could simplify some of the code.

A question, do we need a deprecation type warning if this change is 10x only? One idea I had is that instead or removing the mappings from EnvToSyspropMappings.properties, we could instead have two lists. And if you use the value from the deprecated list, then you get a loud warning in the logs, with the idea that it gets removed in 11?

Tests

Running existing tests. If we add the warning idea, then will need another test.

@epugh epugh changed the title Migrate to env util Migrate to dot seperate naming of environment variables Apr 7, 2025
@epugh epugh requested a review from janhoy April 7, 2025 12:09
@janhoy
Copy link
Contributor

janhoy commented Apr 8, 2025

Great initiative. Warning is a nice thing to add since it is easy in a centralized way, but not strictly required if this is a 10.0 PR and the prop change is documented.

@dsmiley
Copy link
Contributor

dsmiley commented Apr 9, 2025

It's not clear this is needed or matters. In the code I like seeing "solr.<module>.<name>" where the module and name are camel case. But I can get over it.

@epugh
Copy link
Contributor Author

epugh commented Apr 9, 2025

Great initiative. Warning is a nice thing to add since it is easy in a centralized way, but not strictly required if this is a 10.0 PR and the prop change is documented.

Humm, so in messing with this, I am seeing that the properties that I've removed only get set by bin/solr scripts, so maybe they are all internal to Solr?

@epugh
Copy link
Contributor Author

epugh commented Apr 9, 2025

It's not clear this is needed or matters. In the code I like seeing "solr.." wehre the module and name are camel case. But I can get over it.

Thanks for the honest feedback ;-). I'm happy to elaborate on reasons why if helpful ;-)

epugh added 3 commits April 9, 2025 05:59
…ile.types

Use EnvUtils to simplify consulting properties or env variables.
Converts non standard old system properties into the current standard and warns users about upgrading.
epugh added 2 commits April 9, 2025 10:26
Adds a bats test to show the deprecated value still works, but emits a warning to the user.
@HoustonPutman
Copy link
Contributor

Yeah, I'm not sure this is better (and definitely not sure if its worth the effort)

@epugh
Copy link
Contributor Author

epugh commented Apr 9, 2025

We should probably make sure we are all on the same page, before I keep plugging away on this. I, maybe erroneously, assumed that since there was a TODO in the https://github.com/apache/solr/blob/main/solr/solrj/src/resources/EnvToSyspropMappings.properties#L6 file that this was something as a community we had agreed on. Since Solr 10 is coming, I wanted to get this in! I may over value consistency!

@epugh epugh marked this pull request as ready for review April 9, 2025 21:04
@epugh
Copy link
Contributor Author

epugh commented Apr 9, 2025

Okay, before I polish off migrating the rest of the ones in https://github.com/apache/solr/pull/3312/files#diff-012f0766c431d2622a99ac1f70addc1d1f90106816a94434a39db6945db23601, I think this should probably get merged, and then I can do a second batch...?

Copy link

github-actions bot commented Jun 9, 2025

This PR has had no activity for 60 days and is now labeled as stale. Any new activity will remove the stale label. To attract more reviewers, please tag people who might be familiar with the code area and/or notify the [email protected] mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution!

@github-actions github-actions bot added the stale PR not updated in 60 days label Jun 9, 2025
Copy link
Contributor

@janhoy janhoy left a comment

Choose a reason for hiding this comment

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

In SIP-21 (https://cwiki.apache.org/confluence/display/SOLR/System+property+naming+structure) I proposed a solr.<top-cat>.<sub-cat>.<prop>.<name> structure to give users some clue as to which part of solr a variable is for. It was a bit hard to agree on sensible top- and sub-categories, but I gave it a first shot. I made some comments below for how that would change this PR.

Also the comment in the props file was made assuming the community agrees to go this direction. The feedback from the SIP process was largely positive, and I know that more recently named variables have tried to follow this pattern, but no enforcement until you proposed this PR, which I support.

@@ -1766,7 +1766,7 @@ private SolrCore createFromDescriptor(
// this mostly happens when the core is deleted when this node is down
// but it can also happen if connecting to the wrong zookeeper
final boolean deleteUnknownCores =
Boolean.parseBoolean(System.getProperty("solr.deleteUnknownCores", "false"));
Boolean.parseBoolean(System.getProperty("solr.delete.unknown.cores", "false"));
Copy link
Contributor

Choose a reason for hiding this comment

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

solr.cloud.startup.delete.unknown.cores.enabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that this is a painfully long prop, and I kind of agree with Smiley that solr.cloud.startup.deleteUnknownCores would be a better choice. But allowing CamelCase breaks the simple translation rule that you can take an env.var and lowercase it and replace underscores with dots to get the sysprop. Perhaps we could introduce dashes like SOLR_CLOUD_STARTUP_DELETE-UNKNOWN-CORES but it soon gets to complex. Naming has been and is a hard thing.

I'm personally willing to embrace structure and simplified rules for parsing/mapping and sacrifice some readability or brewity. Perhaps further down the road we could build one very simple config parser that instantiates config objects without all the bolier-plate parsing code we have today.

@@ -334,7 +334,7 @@ public String getHeader() {
"Note: (a) Please add '--solr-url http://host:port' parameter if needed (usually on Windows).");
format(
sb,
" (b) Please make sure that all Solr nodes are started with '-Denable.packages=true' parameter.");
" (b) Please make sure that all Solr nodes are started with '-Dsolr.enable.packages=true' parameter.");
Copy link
Contributor

Choose a reason for hiding this comment

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

solr.packages.enabled ?

private static final boolean disabled =
Boolean.parseBoolean(System.getProperty("disableAdminUI", "false"));
Boolean.parseBoolean(System.getProperty("solr.admin.ui.disabled", "false"));
Copy link
Contributor

Choose a reason for hiding this comment

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

solr.ui.disabled ?

enableRemoteStreams = Boolean.getBoolean("solr.enableRemoteStreaming");
enableStreamBody = Boolean.getBoolean("solr.enableStreamBody");
enableRemoteStreams = Boolean.getBoolean("solr.enable.remote.streaming");
enableStreamBody = Boolean.getBoolean("solr.enable.stream.body");
Copy link
Contributor

Choose a reason for hiding this comment

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

solr.requests.streaming.remote.enabled and solr.requests.streaming.body.enabled ?

InputStream stream2 =
EnvUtils.class
.getClassLoader()
.getResourceAsStream("EnvToSyspropDeprecatedMappings.properties")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

More meaninful variable names than stream and stream2.
The file name EnvToSyspropDeprecatedMappings.properties gives impression that this file maps env.variables to sys props, but the file itself says it maps sys props to sys props?

Q: Would it be possible to add deprecations as a section in the existing properties file, perhaps with a prefix deprecated.* to keep it in one place?

@github-actions github-actions bot removed the stale PR not updated in 60 days label Jun 10, 2025
@epugh
Copy link
Contributor Author

epugh commented Jun 10, 2025

Thanks for letting oking at this! I had tuna but out of steam on it but will try and pick it up again and get this batch of changes in. Definitely 10x change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants