Skip to content

SOLR-17697 Use picocli instead of commons-cli - #3254

Merged
janhoy merged 27 commits into
mainfrom
jira/SOLR-17697-picocli
Oct 6, 2026
Merged

janhoy merged 27 commits into
mainfrom
jira/SOLR-17697-picocli

Conversation

@janhoy

@janhoy janhoy commented Mar 11, 2025 •

Copy link
Copy Markdown
Contributor

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

This PR is just a way to visualize the status of the feature branch jira/SOLR-17697-picocli.
Create PRs targeting that branch to tackle individual tasks, and then squash merge into this feature branch once done. Then at the end this branch can be merged (not-squash) into main to preserve each tool porting.

Pick a tool not yet converted from the list below. You'll find a useful LLM prompt template in the JIRA issue linked above. Feel free to link your PR number next to the tool line below to signal that you are working on it. Once merged into the feature-branch, check the checkbox.

Tasks/milestones:

@xtenzQ

xtenzQ commented Mar 21, 2025 •

Copy link
Copy Markdown
Contributor

Actually, I'd like to try to implement PoC for few initial tools.

upd: oh, I didnt notice there is a PR created for this

@janhoy

janhoy commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

upd: oh, I didnt notice there is a PR created for this

Yea, there's an in-progress exploration taking place, feel free to join the discussion about it or POC for yourself on how to solve various issues that arise. We're still trying to land on the most elegant way to introduce things, and I plan to dial down the ambitions for the other PR to do bare minimal for one or two tools, and perhaps the "start" tool. Eventually, when we start getting the grip on how things should flow, it will be easier to jump in and implement PRs for new tools, targeting this branch.

@janhoy
janhoy force-pushed the jira/SOLR-17697-picocli branch from 4ddb026 to 97a673e Compare April 5, 2026 12:45
@janhoy
janhoy force-pushed the jira/SOLR-17697-picocli branch from 97a673e to cb41a69 Compare April 5, 2026 12:50
…n changes

- SolrCLI --version now prints 'Client version:' matching commons-cli output
- ZkConnectionOptions, ConnectionOptions (create/delete) and StatusTool gain
  -s/--solr-connection accepting a ZooKeeper or HTTP(s) connection string,
  with --solr-url now long-only, mirroring CommonCLIOptions on main
- StatusTool picocli target options grouped mutually exclusive like the
  commons-cli OptionGroup; zk/connection targets resolved to a Solr URL via
  new shared CLIUtils.solrUrlFromConnection (extracted from normalizeSolrUrl)
- CliDefaultValueProvider supports SOLR_CONNECTION env default
- test_status.bats accepts both engines' mutual-exclusion error messages

Connection parsing is string-only; network calls happen only at tool
execution time, never during picocli parsing.
@janhoy

janhoy commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

This branch is now up to date with latest main (~250 commits merged in). All of precommit, the CLI unit tests (org.apache.solr.cli.*), and the create/delete/status/version/zk BATS suites pass — the BATS suites in both default commons-cli mode and with SOLR_PICOCLI=true.

What it took, beyond routine conflict resolution:

  • Regenerated all gradle lockfiles (resolveAndLockAll --write-locks plus a precommit --write-locks pass for the jar-check *Copy configurations), and dropped permitUnusedDeclared from test-framework/build.gradle — replaced on main by the opt-in DAGP plugin.
  • Adopted main's move away from direct ZooKeeper access: DeleteTool now resolves its target via CLIUtils.getSolrConnection and deletes configsets through the ConfigSets API (echoing "Connecting to Solr at …"); CreateTool uses the new CloudSolrClientConnection API with the isZookeeper() guard for config upload, and only takes the Solr URL from explicit connection options so the live-node fallback works as on main.
  • Brought the picocli path to parity with main's --solr-connection change (-s now means --solr-connection, --solr-url is long-only) in ZkConnectionOptions, the create/delete ConnectionOptions, and StatusTool — whose picocli target options are now a mutually-exclusive group mirroring the commons-cli OptionGroup. Connection parsing is string-only; network calls happen only at tool execution time, never during picocli parsing.
  • solr --version under picocli now prints Client version: … to match main's new commons-cli output (which also prints Server version: when a connection option is given).
  • Small fixes along the way: defaulted picocli --max-wait-secs to 0 (NPE for plain solr status), and relaxed the test_status.bats mutual-exclusion assertion to accept both engines' error messages (same pattern as test_create.bats).

The zk→live-node URL resolution needed by StatusTool was extracted into CLIUtils.solrUrlFromConnection(), proposed separately against main in #4683 to keep non-picocli drift off this branch.

janhoy added 5 commits July 30, 2026 16:50
Import IOException in ConnectionOptions and picocli.CommandLine in
SolrCLITest instead of using fully qualified names.
The picocli field refactor made the credential-taking overload read the
(unset) field instead of its parameter, so AssertTool's status checks sent
no Authorization header and test_basic_auth.bats failed with 401.
…ages

Project.javaexec was removed in Gradle 9 (which arrived with the main
merge); use injected ExecOperations as done in gradle/globals.gradle.
Regenerated pages/cli to reflect the new -s/--solr-connection option
group on status, create, delete and zk subcommands.
# Conflicts:
#	solr/core/src/java/org/apache/solr/cli/AuthTool.java
Resolved conflicts in gradle/libs.versions.toml (kept picocli, took main's
prometheus-metrics 1.8.0) and in gradle.lockfiles (took main's, then
regenerated with resolveAndLockAll to re-add picocli entries).
Ran updateLicenses, which removed stale bcprov/bcutil 1.81.1 sha1 files.
@janhoy

janhoy commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Please check out #4909 which sits on top of this one. That PR intends to prepare this branch for merge to main and branch_10x already now, before all tools are converted. My motivation is to get what we have out there and simplify work on remaining tool migrations as they can happen as full-blown PRs and land in the next releaase.

As you'll see of that PR description, it is all back compat, users wont notice it is there, and the ref guide changes are moved into its own page with all the new generated man pages as children, so even the ref guide is opt-in for those interested.

@janhoy

janhoy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Merged in the other PR, and now this should be ready for inclusion in main, since picocli code is now fully opt-in and the docs are separate, add-only, not edit.

@sigram I't's up to you whether it can also land on branch_10x for 10.1. I'm happy to let it sit on main for a while and then merge to 10x after the 10.1 release.

@janhoy
janhoy marked this pull request as ready for review September 18, 2026 14:32
@janhoy
janhoy requested a review from epugh September 18, 2026 14:33
@janhoy

janhoy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@epugh, @jaykay12 The plan now is to

  • merge this PR to main (only main for now)
  • rebase your in-flight packageTool PR on top of main (sorry)
  • create separate JIRA issues for each group of remaining tools still open in this PR description. By group I mean that the Snapshot*Tools should be one JIRA and one PR since they will be related.

janhoy added 3 commits October 6, 2026 14:12
Conflicts resolved:
 - DeleteTool: adopt main's SOLR-18321 rewrite (collection status + configset
   V2 APIs via a plain SolrClient, --force now a deprecated no-op) and rewire
   the picocli path onto it, dropping the old ZooKeeper cluster-state scan.
 - Regenerated all gradle lockfiles to restore the cliDocsRuntime
   configuration alongside main's dependency updates.
Correct the stale "--delete-config ... default is true" wording: SOLR-17495
made config deletion opt-in but never updated the description. Keep the
now-no-op --force documented, so existing scripts find out it has no effect.
Regenerate the CLI ref-guide page.
…path

The CreateParams refactor resolved the Solr URL only when a connection flag
was passed on the command line, so SOLR_CONNECTION / ZK_HOST coming from the
environment no longer reached createCore's existence check or the _default
configset warning; both silently fell back to the default localhost URL.
Since safeCheckCoreExists swallows connection errors, the "core already
exists" guard was skipped rather than reported.

Pass the fully resolved URL and track separately whether a connection option
was actually given, which is what createCollection needs to decide between an
explicit target and a live node.
@janhoy
janhoy merged commit b6b2b8f into main Oct 6, 2026
10 checks passed
@janhoy
janhoy deleted the jira/SOLR-17697-picocli branch October 6, 2026 13:37
@janhoy janhoy added this to the 10.x milestone Oct 6, 2026
dsmiley pushed a commit that referenced this pull request Oct 8, 2026
Adds picocli alongside the existing commons-cli parser. Picocli is
opt-in and off by default: set SOLR_PICOCLI=true

Commands ported to picocli in this change:

  start, stop, status, version, auth, create, delete
  zk: cp, ls, mv, rm, mkroot, upconfig, downconfig, updateacls

Remaining commands still run on commons-cli and are tracked in
follow-up issues. Per-command ref guide pages are now generated from
the picocli annotations.

Co-authored-by: Eric Pugh <epugh@opensourceconnections.com>
(cherry picked from commit b6b2b8f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment