This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 76d3341df10 SOLR-17511: Deprecate -i CLI usages (#2794)
76d3341df10 is described below
commit 76d3341df10aef4f686a17838621545fc28a3c70
Author: Eric Pugh <[email protected]>
AuthorDate: Mon Oct 28 09:10:02 2024 -0400
SOLR-17511: Deprecate -i CLI usages (#2794)
Co-authored-by: Christos Malliaridis <[email protected]>
---
.../org/apache/solr/cli/SnapshotExportTool.java | 19 ++++++++++++++++++-
solr/packaging/test/test_prometheus.bats | 3 ++-
solr/prometheus-exporter/bin/solr-exporter | 2 +-
solr/prometheus-exporter/bin/solr-exporter.cmd | 2 +-
.../solr/prometheus/exporter/SolrExporter.java | 21 ++++++++++++++++++++-
.../apache/solr/prometheus/scraper/SolrScraper.java | 3 ++-
.../monitoring-with-prometheus-and-grafana.adoc | 2 +-
.../pages/solr-control-script-reference.adoc | 4 ++--
8 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cli/SnapshotExportTool.java
b/solr/core/src/java/org/apache/solr/cli/SnapshotExportTool.java
index c7a1578ca5e..9cc5668d6c3 100644
--- a/solr/core/src/java/org/apache/solr/cli/SnapshotExportTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/SnapshotExportTool.java
@@ -20,6 +20,7 @@ import java.io.PrintStream;
import java.util.List;
import java.util.Optional;
import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DeprecatedAttributes;
import org.apache.commons.cli.Option;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -78,6 +79,19 @@ public class SnapshotExportTool extends ToolBase {
"Specifies name of the backup repository to be used during
snapshot export preparation.")
.build(),
Option.builder("i")
+ .deprecated(
+ DeprecatedAttributes.builder()
+ .setForRemoval(true)
+ .setSince("9.8")
+ .setDescription("Use --async-id instead")
+ .get())
+ .argName("ID")
+ .hasArg()
+ .required(false)
+ .desc(
+ "Specifies the async request identifier to be used during
snapshot export preparation.")
+ .build(),
+ Option.builder()
.longOpt("async-id")
.argName("ID")
.hasArg()
@@ -91,12 +105,15 @@ public class SnapshotExportTool extends ToolBase {
@Override
public void runImpl(CommandLine cli) throws Exception {
SolrCLI.raiseLogLevelUnlessVerbose(cli);
- //
+
String snapshotName = cli.getOptionValue("snapshot-name");
String collectionName = cli.getOptionValue("name");
String destDir = cli.getOptionValue("dest-dir");
Optional<String> backupRepo =
Optional.ofNullable(cli.getOptionValue("backup-repo-name"));
Optional<String> asyncReqId =
Optional.ofNullable(cli.getOptionValue("async-id"));
+ if (cli.hasOption("i")) {
+ asyncReqId = Optional.ofNullable(cli.getOptionValue("i"));
+ }
try (var solrClient = SolrCLI.getSolrClient(cli)) {
exportSnapshot(solrClient, collectionName, snapshotName, destDir,
backupRepo, asyncReqId);
diff --git a/solr/packaging/test/test_prometheus.bats
b/solr/packaging/test/test_prometheus.bats
index 7a6555ef7a6..a6dc1c2671d 100644
--- a/solr/packaging/test/test_prometheus.bats
+++ b/solr/packaging/test/test_prometheus.bats
@@ -38,7 +38,7 @@ teardown() {
assert_output --partial "Created new core 'COLL_NAME'"
echo "# starting solr-exporter on ${SOLR_EXPORTER_PORT}" >&3
- run solr-exporter -p $SOLR_EXPORTER_PORT -b
http://localhost:${SOLR_PORT}/solr >&3 &
+ run solr-exporter --cluster-id bats-test -p $SOLR_EXPORTER_PORT -b
http://localhost:${SOLR_PORT}/solr >&3 &
sleep 5
@@ -46,4 +46,5 @@ teardown() {
assert_output --partial 'solr_metrics_core_query_requests_total'
assert_output --partial 'core="COLL_NAME"'
+ assert_output --partial 'bats-test'
}
diff --git a/solr/prometheus-exporter/bin/solr-exporter
b/solr/prometheus-exporter/bin/solr-exporter
index 87109649151..452e597ab55 100755
--- a/solr/prometheus-exporter/bin/solr-exporter
+++ b/solr/prometheus-exporter/bin/solr-exporter
@@ -126,7 +126,7 @@ elif [[ -n "$SOLR_URL" ]]; then
fi
if [[ -n "$CLUSTER_ID" ]]; then
- EXPORTER_ARGS+=(-i "$CLUSTER_ID")
+ EXPORTER_ARGS+=(--cluster-id "$CLUSTER_ID")
fi
if [[ -n "$CREDENTIALS" ]]; then
diff --git a/solr/prometheus-exporter/bin/solr-exporter.cmd
b/solr/prometheus-exporter/bin/solr-exporter.cmd
index aa861da7c97..7e9dd2a91f2 100644
--- a/solr/prometheus-exporter/bin/solr-exporter.cmd
+++ b/solr/prometheus-exporter/bin/solr-exporter.cmd
@@ -82,7 +82,7 @@ IF NOT "%SCRAPE_INTERVAL%"=="" set
EXPORTER_ARGS=%EXPORTER_ARGS% --scrape-interv
IF NOT "%NUM_THREADS%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% --num-threads
%NUM_THREADS%
IF NOT "%ZK_HOST%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -z %ZK_HOST%
IF NOT "%SOLR_URL%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -b %SOLR_URL%
-IF NOT "%CLUSTER_ID%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -i "%CLUSTER_ID%"
+IF NOT "%CLUSTER_ID%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% --cluster-id
"%CLUSTER_ID%"
IF NOT "%CREDENTIALS%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -u "%CREDENTIALS%"
IF NOT "%SSL_ENABLED%"=="" set EXPORTER_ARGS=%EXPORTER_ARGS% -ssl
"%SSL_ENABLED%"
goto endInit
diff --git
a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
index 4c40b08e849..2a839b0c794 100644
---
a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
+++
b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
@@ -203,7 +203,7 @@ public class SolrExporter {
mainOptions.addOption(helpOption);
Option clusterIdOption =
- Option.builder("i")
+ Option.builder()
.longOpt("cluster-id")
.hasArg()
.argName("CLUSTER_ID")
@@ -213,6 +213,22 @@ public class SolrExporter {
.build();
mainOptions.addOption(clusterIdOption);
+ Option clusterIdDepOption =
+ Option.builder("i")
+ .deprecated(
+ DeprecatedAttributes.builder()
+ .setForRemoval(true)
+ .setSince("9.8")
+ .setDescription("Use --cluster-id instead")
+ .get())
+ .hasArg()
+ .argName("CLUSTER_ID")
+ .type(String.class)
+ .desc(
+ "Specify a unique identifier for the cluster, which can be
used to select between multiple clusters in Grafana. By default this ID will be
equal to a hash of the -b or -z argument")
+ .build();
+ deprecatedOptions.addOption(clusterIdDepOption);
+
Option numThreadsOption =
Option.builder()
.longOpt("num-threads")
@@ -356,6 +372,9 @@ public class SolrExporter {
int port = commandLine.getParsedOptionValue(portOption, DEFAULT_PORT);
String clusterId = commandLine.getOptionValue(clusterIdOption,
DEFAULT_CLUSTER_ID);
+ if (commandLine.hasOption("i")) {
+ clusterId = commandLine.getOptionValue("i");
+ }
if (StrUtils.isNullOrEmpty(clusterId)) {
clusterId = defaultClusterId;
}
diff --git
a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/scraper/SolrScraper.java
b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/scraper/SolrScraper.java
index 273f6826176..5bc4d720b1b 100644
---
a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/scraper/SolrScraper.java
+++
b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/scraper/SolrScraper.java
@@ -184,7 +184,8 @@ public abstract class SolrScraper implements Closeable {
labelValues.add(zkHostLabelValue);
}
- // Add the unique cluster ID, either as specified on cmdline -i or
baseUrl/zkHost
+ // Add the unique cluster ID, either as specified on cmdline
--cluster-id or
+ // baseUrl/zkHost
labelNames.add(CLUSTER_ID_LABEL);
labelValues.add(clusterId);
diff --git
a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
index aa19811fea2..898be24b339 100644
---
a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
+++
b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
@@ -171,7 +171,7 @@ The `solr-exporter` collects metrics from Solr every few
seconds controlled by t
These metrics are cached and returned regardless of how frequently prometheus
is configured to pull metrics from this tool.
The freshness of the metrics can be improved by reducing the scrape interval
but do not set it to a very low value because metrics collection can be
expensive and can execute arbitrary searches to ping Solr.
-`-i`, `--cluster-id`, `$CLUSTER_ID`::
+`--cluster-id`, `$CLUSTER_ID`::
+
[%autowidth,frame=none]
|===
diff --git
a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
index e66b591280b..5d51d643a96 100644
---
a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
+++
b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
@@ -1869,10 +1869,10 @@ Use the export command to take :
[,console]
----
-$ bin/solr snapshot-export [--backup-repo-name <DIR>] -c <NAME> --dest-dir
<DIR> [-i <ID>] --snapshot-name <NAME>
+$ bin/solr snapshot-export [--backup-repo-name <DIR>] -c <NAME> --dest-dir
<DIR> [--async-id <ID>] --snapshot-name <NAME>
----
-The `-i` parameter specifies that this is an asynchronous process.
+The `--async-id` parameter specifies that this is an asynchronous process.
=== Delete a Snapshot