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-16800: Move towards using the root of Solr as the -solrUrl in the CLI. #1808

Merged
merged 27 commits into from
Aug 8, 2023

Conversation

epugh
Copy link
Contributor

@epugh epugh commented Jul 25, 2023

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

Description

In the future we'll have V2 API urls that are under /api, so having urls be /solr is a bit awkward. Allow -solrUrl http://localhost:8983 to work, and warn on http://localhost:8983/solr.

Some other cleanups as well.

Solution

Use the SolrCLI.getSolrClient method through out the client Tool's.

Tests

bats tests

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)
  • 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

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

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

LGTM, despite a few minor in-line suggestions.

@@ -383,6 +383,11 @@ public static boolean exceptionIsAuthRelated(Exception exc) {
}

public static SolrClient getSolrClient(String solrUrl) {
// today we require all urls to end in /solr, however in the future we will need to support the
// /api url end point instead.
if (!solrUrl.endsWith(("/solr"))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[0] Not sure whether this is intended or not, but if the provided URL was http://localhost:8983/solr/ (not the ending '/') we'd still append/solr. I wonder if there isn't some Java utility for adding path segments to a URL that can be a little smarter about some of the edge cases (handling adjacent forward slashes, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this kind of made me sad... basically I was trying to write both code to handle legacy /solr type urls, but then, since everything TODAY requries a /solr url, then to inject it here. Have we figured out how in the future to hit a V2 api that has an /api end point instead via a SolrClient? My hope is once that is solved then we remove this logic.
Having said that, if there is better code to use here, would love some of that! I hope that before 10x gets released, this code will be eliminated, so I kind of just put this in "for now".... I don't expect to backport this to 9x.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh... One test has "http://127.0.0.1:51902/uf_" as the URL.....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait... why do tests now have solr urls that end in /solr??? Now I wonder if they also stand up Solr servers that don't use /api for the v2 api endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I've pulled in main that has the now hardcoded hostContext...

if (solrUrl.indexOf("/solr") > -1) { //
solrUrl = solrUrl.substring(0, solrUrl.indexOf("/solr"));
CLIO.out(
"The solrUrl parameter only needs to only point to the root of Solr ("
Copy link
Contributor

Choose a reason for hiding this comment

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

[-0] I think this message would read more clearly if you dropped the second "only".

[0] Maybe add some indication in this message that Solr is able to auto-correct the URL for folks, so they don't see the warning and think the command has failed. e.g.

'solrUrl' needn't include Solr's context-root (e.g. "/solr"); correcting from [old] to [new]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Love it... pushing up fix.

@epugh
Copy link
Contributor Author

epugh commented Jul 31, 2023

This PR is held up on getting SOLR-16911, PR #1810 committed first....

@epugh
Copy link
Contributor Author

epugh commented Aug 6, 2023

@chatman I've got some optimizations to the Package tool if you want to look. @gerlowskija I'd love another looksee now that hostContext has been sorted....

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

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

Few small nits, but looks mostly good. Thanks for taking this on!

solr/core/src/java/org/apache/solr/cli/SolrCLI.java Outdated Show resolved Hide resolved
solr/core/src/java/org/apache/solr/cli/SolrCLI.java Outdated Show resolved Hide resolved
solr/core/src/java/org/apache/solr/cli/SolrCLI.java Outdated Show resolved Hide resolved
solr/core/src/test/org/apache/solr/cli/SolrCLITest.java Outdated Show resolved Hide resolved
solr/core/src/java/org/apache/solr/cli/SolrCLI.java Outdated Show resolved Hide resolved
@epugh epugh requested a review from gerlowskija August 8, 2023 11:17
@epugh epugh dismissed gerlowskija’s stale review August 8, 2023 11:18

while clicking dismiss, it's because I responded to everything!

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

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

LGTM

@epugh epugh merged commit 44668dc into apache:main Aug 8, 2023
3 of 4 checks passed
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.

2 participants