Skip to content
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

SOLR-15960 Unified use of system properties and environment variables #1935

Merged
merged 43 commits into from
Jan 5, 2024

Conversation

janhoy
Copy link
Contributor

@janhoy janhoy commented Sep 17, 2023

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

This is a first step, demonstrating how we can skip converting env.vars like SOLR_FOO in bin/solr and then passing them as -Dsolr.foo. Instead we just provide Solr with all the SOLR_* environment variables, and let the new EnvUtils class convert and set the proper system propertis. Our Solr code can then continue reading System.getProperty("solr.foo") as before.

We have some exceptions to the naming convention, and for those there is a properties file to map ENV -> prop key.

Some places in Solr we look for either env.var or sys.prop and pick the one that exists. This is no longer necessary, as you can just read the sys.prop and it will be set if the corresponding ENV was passed to Solr.

This PR gives a few examples of cleanup that can be done, by removing explicit parsing of SOLR_LOG_LEVEL and SOLR_MODULES from start scripts. Tons of other places can also be simplified, but to keep this PR small, this is probably a nice first step, then other can follow in other PRs.

@janhoy janhoy marked this pull request as draft September 17, 2023 20:44
@janhoy janhoy marked this pull request as ready for review September 18, 2023 07:39
@janhoy janhoy requested a review from epugh September 18, 2023 07:39
@janhoy
Copy link
Contributor Author

janhoy commented Sep 18, 2023

Tests pass, @epugh can you have a first quick review and tell if this helps your CLI work? After your first feedback I can invite more reviewers.

I feel the principle is well proven by the fact that I removed explicit parsing of SOLR_MODULES variable in bin/solr, and still test_modules.bats pass tests both for -Dsolr.modules and export SOLR_MODULES.

I want to keep the scope of this PR somewhat limited. Can follow up with new PRs that remove cruft from the scripts.

solr/bin/solr Show resolved Hide resolved
solr/bin/solr Show resolved Hide resolved
@epugh
Copy link
Contributor

epugh commented Sep 18, 2023

Would then the preferred access mode for getting properties be via EnvUtils.getProp(SolrDispatchFilter.SOLR_DEFAULT_CONFDIR_ATTRIBUTE) pattern? I could imagine in a future ticket getting rid of the System.getPRoperty and adding that to our list of disallowed methods ;-). One more thought, how did you build the list of nonstandard mappings?

@janhoy
Copy link
Contributor Author

janhoy commented Sep 19, 2023

Would then the preferred access mode for getting properties be via EnvUtils.getProp(SolrDispatchFilter.SOLR_DEFAULT_CONFDIR_ATTRIBUTE) pattern? I could imagine in a future ticket getting rid of the System.getPRoperty and adding that to our list of disallowed methods ;-). One more thought, how did you build the list of nonstandard mappings?

Such moves can be considered for sure. The EnvUtils.getProp() method does not bring much to the table, but the other variants such as getPropAsList() etc are helpful, but still a convenience on top of the props. I may have duplicated similar logic from other Solr Util classes, so happy to consolidate if you know of something.

Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

This looks like a great step in the right direction! I don't yet have like a immediate "hey, this totally solved one of the CLI issues", but I bet it helps. Bigger is that in the future, maybe folks can use either system properties or environment variables to configure Solr without it being a battle ;-).

@janhoy
Copy link
Contributor Author

janhoy commented Dec 9, 2023

Thanks for your review @dsmiley and sorry for late response. I updated PR.

@janhoy
Copy link
Contributor Author

janhoy commented Dec 9, 2023

In 28400bb I removed yet 20 lines from bin/solr :)

@janhoy
Copy link
Contributor Author

janhoy commented Dec 23, 2023

@HoustonPutman Thanks to your BATS ssl tests, we caught a problem in this PR. Needed to exclude all SOLR_SSL_* vars from auto conversion to SysProp.

@janhoy
Copy link
Contributor Author

janhoy commented Dec 25, 2023

Disabled locking and tests pass. I seem to recall that the GlobalCircuitBreaker tests would break. I’ll try some beasting over Christmas..

@janhoy
Copy link
Contributor Author

janhoy commented Dec 26, 2023

Could not make the CB tests fail with beasting. So I fully removed all locking code. We'll soon discover if there are issues.

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Thanks for getting back to something simpler :-)

@janhoy
Copy link
Contributor Author

janhoy commented Jan 4, 2024

Thanks for the extra review. Will merge to main tomorrow.

@epugh
Copy link
Contributor

epugh commented Jan 4, 2024

I went to check if Ref Guide was updated, and sure enough it was!

@janhoy janhoy merged commit 10bbabb into apache:main Jan 5, 2024
4 checks passed
janhoy added a commit that referenced this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants