Skip to content

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

Open
VishnuPriyaChandraSekar wants to merge 1 commit intoapache:mainfrom
VishnuPriyaChandraSekar:SOLR-18055-zkstateReader-urlScheme
Open

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

Conversation

@VishnuPriyaChandraSekar
Copy link
Copy Markdown
Contributor

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

  • Currently, HttpShardHandlerFactory detects the url scheme from the configuration file (<str name="urlScheme">${urlScheme:}</str> in solr.xml). In this PR, it detects the url scheme based on the system property ("solr.ssl.enabled").
  • ZKStateReader.getBaseUrlForNodeName() and getBaseUrlV2ForNodeName() uses cluster property to detect the url scheme for the nodes. In this PR, it detects the url scheme either from system property ("solr.ssl.enabled") or cluster property
  • Additionally, I deprecated the usage of Cluster property in ZkController, ReplicaMutator, SliceMutator and SystemInfoProvider

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 (Not required)

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

}

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)

/**
* 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

*
* @return http or https
*/
private String getUrlScheme() {
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.

As a method it's suggestive for anyone to potentially call it beyond the only caller -- init(). Notice that init() is only trying to initialize this.scheme and that null is very valid; see buildUrl(). So lets just do that without this method here, leaving it as null if the sys prop isn't set.

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.

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