Skip to content

SOLR-18055 Use solr.ssl.enabled property for url scheme detection#4272

Draft
VishnuPriyaChandraSekar wants to merge 4 commits intoapache:mainfrom
VishnuPriyaChandraSekar:SOLR-18055-zkstateReader-urlScheme
Draft

SOLR-18055 Use solr.ssl.enabled property for url scheme detection#4272
VishnuPriyaChandraSekar wants to merge 4 commits intoapache:mainfrom
VishnuPriyaChandraSekar:SOLR-18055-zkstateReader-urlScheme

Conversation

@VishnuPriyaChandraSekar
Copy link
Copy Markdown
Contributor

@VishnuPriyaChandraSekar VishnuPriyaChandraSekar commented Apr 9, 2026

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

Description

Currently, the client is compelled to provide cluster property in order to indicate the url scheme. This is annoying. In this PR, the url scheme is detected using the "solr.ssl.enabled" system property instead of cluster property.

Solution

  • Improved HttpShardHandlerFactory's url scheme detection by giving higher precedence for "solr.ssl.enabled" over explicit configuration from solr.xml
  • Improved ZkStateReader's url scheme detection by giving higher precedence for "solr.ssl.enabled" over cluster property
  • Deprecated the usage of Cluster property in ZkController, ReplicaMutator, SliceMutator and SystemInfoProvider. These classes will depend on ClusterStateProvider to know the url scheme.

Tests

  • Added new test cases in ZKStateReader to verify the correctness of getUrlScheme
  • Replaced "urlScheme" system property by "solr.ssl.enabled" in the following test files
    - SolrTestCaseJ4.java
    - TestMiniSolrCloudClusterSSL.java
  • Removed the usage of urlScheme in the solr configuration files
  • Modified the existing tests in solr/solrj/src/test/org/apache/solr/client/solrj/impl/ClusterStateProviderTest.java

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

Copy link
Copy Markdown
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.
Remember to ./gradle writeChangelog too

Comment thread solr/core/src/java/org/apache/solr/cloud/ZkController.java
Comment thread solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java Outdated
}

private void testUrlSchemeDefault(SolrZkClient client) throws Exception {
if (isSSLMode()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are you this back & forth? in some methods?

Copy link
Copy Markdown
Contributor Author

@VishnuPriyaChandraSekar VishnuPriyaChandraSekar Apr 9, 2026

Choose a reason for hiding this comment

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

Looks like the baseClass (SolrTestCaseJ4) randomly runs the server in SSL mode. Thus, I had to put back the system property if the server runs in https (If I don't do this, the next consecutive tests becomes flaky)

Comment thread solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java Outdated
/**
* Deduce url scheme using environment variable if available otherwise from cluster property
*
* @return url scheme of host
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

show the 2 examples please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will add some in the next revision

Comment thread solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java Outdated
Comment thread solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java Outdated
new RequestReplicaListTransformerGenerator();

// URL scheme to be used in distributed search.
static final String INIT_URL_SCHEME = "urlScheme";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious; was urlScheme arg documented in the ref guide or present in a published solr.xml that people use? If so we'll want to keep it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like urlScheme is an optional field in solr.xml [1]. In order to provide backward compatibility, I think the precedence to lookup the urlScheme should be 1) solr.ssl.enabled 2) urlScheme from solr.xml 3) default (null).

[1] https://solr.apache.org/guide/solr/latest/configuration-guide/configuring-solr-xml.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. Thanks for looking into it.

@VishnuPriyaChandraSekar VishnuPriyaChandraSekar marked this pull request as draft April 15, 2026 22:18
@@ -1,8 +1,15 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: Improved CloudSolrClient's urlScheme detection by using the scheme of provided Solr URLs, or looking at "solr.ssl.enabled".
title: Improved url scheme detection in client API and core components
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO this has become much more vague to a reader of the changelog who is anyone other than you and me. The "title" label is misleading -- add more sentences.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about this "Standardize urlScheme detection with precedence for "solr.ssl.enabled" ?

url: https://issues.apache.org/jira/browse/SOLR-18056
- name: SOLR-18055
url: https://issues.apache.org/jira/browse/SOLR-18055
important_notes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the first I've seen of this... and you are the first to attempt to use it :-) Our only references to it thus far don't even truly say what it's for.
Documentation. Seems for "breaking changes" or presumably anything befitting of that label. What you added doesn't qualify IMO.

Well the "deprecated" part does... albeit I think I said it's premature to deprecate that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, there is no other field I could use for.
Based on this, I will just have a self descriptive title (IMO this is the hardest part) like "Standardize urlScheme detection by prioritizing "solr.ssl.enabled" over solr.xml and cluster property"

Comment on lines +437 to +444
*
* <p>Examples:
*
* <ul>
* <li>Returns {@code "https"} when SSL is enabled via configuration.
* <li>Returns {@code null} when ssl is disabled or no explicit configuration is provided in
* solr.xml.
* </ul>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sorry, this is way too much documentation for a private method

*
* @return http or https or null
*/
private String getUrlScheme(NamedList<?> args, StringBuilder sb) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe prefix with 'init' not 'get' to emphasize this is for initialization and not any method in this class that might want it. On further reflection, there's getParameter called by init() a bunch of times. This method here was merely extracted from init(). You could put it back. Or call it getParameterUrlScheme

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense :)

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.

2 participants