You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2024/11/08 12:34:07 UTC

(solr) branch main updated: SOLR-17495: Change CLI delete command to not delete configs by default. (#2761)

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 b8cbe41b86a SOLR-17495: Change CLI delete command to not delete configs by default. (#2761)
b8cbe41b86a is described below

commit b8cbe41b86a6aac4f93dbbbe972af8451111a66d
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Fri Nov 8 07:34:02 2024 -0500

    SOLR-17495: Change CLI delete command to not delete configs by default. (#2761)
    
    Decouples the lifecycle of a collection and a configset when using bin/solr delete.
---
 solr/CHANGES.txt                                           |  2 ++
 solr/core/src/java/org/apache/solr/cli/DeleteTool.java     | 11 +++--------
 solr/core/src/test/org/apache/solr/cli/DeleteToolTest.java |  2 --
 solr/packaging/test/bats_helper.bash                       |  2 +-
 solr/packaging/test/test_basic_auth.bats                   |  3 ++-
 solr/packaging/test/test_delete_collection.bats            |  8 +++++---
 .../pages/solr-control-script-reference.adoc               | 14 +++++++-------
 .../upgrade-notes/pages/major-changes-in-solr-10.adoc      |  3 +++
 8 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0076975aec7..244f68171b7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -28,6 +28,8 @@ Improvements
 
 * SOLR-17544: Solr CLI will now stop when you combine mutually exclusive options.  Combining -s and -z options is a common example.  (Eric Pugh, Christos Malliaridis)
 
+* SOLR-17495: Change Solr CLI delete command to not delete configs by default.  Decouple lifecycle of collections from configsets. (Eric Pugh)
+
 Optimizations
 ---------------------
 (No changes)
diff --git a/solr/core/src/java/org/apache/solr/cli/DeleteTool.java b/solr/core/src/java/org/apache/solr/cli/DeleteTool.java
index 61e02161416..2c42f8dc030 100644
--- a/solr/core/src/java/org/apache/solr/cli/DeleteTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/DeleteTool.java
@@ -57,9 +57,6 @@ public class DeleteTool extends ToolBase {
   private static final Option DELETE_CONFIG_OPTION =
       Option.builder()
           .longOpt("delete-config")
-          .hasArg()
-          .argName("true|false")
-          .type(Boolean.class)
           .desc(
               "Flag to indicate if the underlying configuration directory for a collection should also be deleted; default is true.")
           .build();
@@ -86,10 +83,8 @@ public class DeleteTool extends ToolBase {
 
   @Override
   public String getHeader() {
-    return "Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud"
-        + " mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also"
-        + " delete the configuration directory from Zookeeper so long as it is not being used by another collection.\n"
-        + " You can override this behavior by passing --delete-config false when running this command.\n"
+    return "Deletes a collection or core depending on whether Solr is running in SolrCloud or standalone mode. "
+        + "Deleting a collection does not delete it's configuration unless you pass in the --delete-config flag.\n"
         + "\n"
         + "List of options:";
   }
@@ -148,7 +143,7 @@ public class DeleteTool extends ToolBase {
 
     String configName =
         zkStateReader.getClusterState().getCollection(collectionName).getConfigName();
-    boolean deleteConfig = Boolean.parseBoolean(cli.getOptionValue(DELETE_CONFIG_OPTION, "true"));
+    boolean deleteConfig = cli.hasOption(DELETE_CONFIG_OPTION);
 
     if (deleteConfig && configName != null) {
       if (cli.hasOption(FORCE_OPTION)) {
diff --git a/solr/core/src/test/org/apache/solr/cli/DeleteToolTest.java b/solr/core/src/test/org/apache/solr/cli/DeleteToolTest.java
index 8f66d104d4e..45c48697663 100644
--- a/solr/core/src/test/org/apache/solr/cli/DeleteToolTest.java
+++ b/solr/core/src/test/org/apache/solr/cli/DeleteToolTest.java
@@ -60,8 +60,6 @@ public class DeleteToolTest extends SolrCloudTestCase {
       "delete",
       "-c",
       "testDeleteCollectionWithBasicAuth",
-      "--delete-config",
-      "false",
       "-z",
       cluster.getZkClient().getZkServerAddress(),
       "--credentials",
diff --git a/solr/packaging/test/bats_helper.bash b/solr/packaging/test/bats_helper.bash
index 68c29686a99..2d8fbb18375 100644
--- a/solr/packaging/test/bats_helper.bash
+++ b/solr/packaging/test/bats_helper.bash
@@ -71,7 +71,7 @@ delete_all_collections() {
   local collection_list="$(solr zk ls /collections -z localhost:${ZK_PORT})"
   for collection in $collection_list; do
     if [[ -n $collection ]]; then
-      solr delete -c $collection >/dev/null 2>&1
+      solr delete -c $collection --delete-config >/dev/null 2>&1
     fi
   done
 }
diff --git a/solr/packaging/test/test_basic_auth.bats b/solr/packaging/test/test_basic_auth.bats
index 333d5cf73d3..a84d9d15d4a 100644
--- a/solr/packaging/test/test_basic_auth.bats
+++ b/solr/packaging/test/test_basic_auth.bats
@@ -57,9 +57,10 @@ teardown() {
   assert_output --partial '"numFound":0'
   
   # Test delete
-  run solr delete --credentials name:password -c COLL_NAME -z localhost:${ZK_PORT} --verbose
+  run solr delete --credentials name:password -c COLL_NAME -z localhost:${ZK_PORT} --delete-config --verbose
   assert_output --partial "Deleted collection 'COLL_NAME'"
   refute collection_exists "COLL_NAME"
+  refute config_exists "COLL_NAME"
   
 }
 
diff --git a/solr/packaging/test/test_delete_collection.bats b/solr/packaging/test/test_delete_collection.bats
index d5db4263e70..0ff455d1b27 100644
--- a/solr/packaging/test/test_delete_collection.bats
+++ b/solr/packaging/test/test_delete_collection.bats
@@ -44,6 +44,7 @@ teardown() {
 
   solr delete -c "COLL_NAME"
   refute collection_exists "COLL_NAME"
+  assert config_exists "COLL_NAME"
 }
 
 @test "can delete collections with solr-url" {
@@ -52,13 +53,14 @@ teardown() {
 
   solr delete -c "COLL_NAME" --solr-url http://localhost:${SOLR_PORT}
   refute collection_exists "COLL_NAME"
+  assert config_exists "COLL_NAME"
 }
 
 @test "collection delete also deletes zk config" {
   solr create -c "COLL_NAME"
   assert config_exists "COLL_NAME"
 
-  solr delete -c "COLL_NAME"
+  solr delete -c "COLL_NAME" --delete-config
   refute config_exists "COLL_NAME"
 }
 
@@ -66,7 +68,7 @@ teardown() {
   solr create -c "COLL_NAME" -n "NONDEFAULT_CONFIG_NAME"
   assert config_exists "NONDEFAULT_CONFIG_NAME"
 
-  solr delete -c "COLL_NAME"
+  solr delete -c "COLL_NAME" --delete-config
   refute config_exists "NONDEFAULT_CONFIG_NAME"
 }
 
@@ -74,6 +76,6 @@ teardown() {
   solr create -c "COLL_NAME"
   assert config_exists "COLL_NAME"
 
-  solr delete -c "COLL_NAME" --delete-config false
+  solr delete -c "COLL_NAME"
   assert config_exists "COLL_NAME"
 }
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 c0e18e46091..49b4ffab143 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
@@ -794,10 +794,10 @@ The `delete` command detects the mode that Solr is running in and then deletes t
 
 `bin/solr delete --help`
 
-If you're deleting a collection in SolrCloud mode, the default behavior is to also delete the configuration directory from Zookeeper so long as it is not being used by another collection.
+If you're deleting a collection in SolrCloud mode, the default behavior is to leave the configuration directory in Zookeeper. If you want to delete the configuration then you need to pass in `--delete-config` as well.
 
-For example, if you created a collection with `bin/solr create -c contacts`, then the delete command `bin/solr delete -c contacts` will check to see if the `/configs/contacts` configuration directory is being used by any other collections.
-If not, then the `/configs/contacts` directory is removed from ZooKeeper.  You can override this behavior by passing `--delete-config false` when running this command.atom
+For example, if you created a collection with `bin/solr create -c contacts`, then the delete command `bin/solr delete -c contacts --delete-config` will check to see if the `/configs/contacts` configuration directory is being used by any other collections.
+If not, then the `/configs/contacts` directory is removed from ZooKeeper.
 
 ==== Delete Collection or Core Parameters
 
@@ -816,14 +816,14 @@ Name of the collection or core to delete.
 +
 [%autowidth,frame=none]
 |===
-|Optional |Default: `true`
+|Optional |Default: none
 |===
 +
-Whether or not the configuration directory should also be deleted from ZooKeeper.
+Specify the configuration directory should also be deleted from ZooKeeper.
 +
-If the configuration directory is being used by another collection, then it will not be deleted even if you pass `--delete-config` as `true`.
+If the configuration directory is being used by another collection, then it will not be deleted.
 +
-*Example*: `bin/solr delete --delete-config false`
+*Example*: `bin/solr delete --delete-config`
 
 `-f` or `--force`::
 +
diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
index af10bc83cff..33440aec93b 100644
--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
@@ -44,6 +44,9 @@ Some key changes that you may run into are:
  
 To learn about the updated options in each CLI tool, use the `--help` option or look up the tool in the documentation.
 
+Additionally, the `bin/solr delete` command no longer deletes a configset when you delete a collection.  Previously if you deleted a collection, it would also delete it's associated configset if it was the only user of it.  
+Now you have to explicitly provide a  `--delete-config` option to delete the configsets.  This decouples the lifecycle of a configset from that of a collection.
+
 === SolrJ
 
 * Starting in 10, the Maven POM for SolrJ does not refer to SolrJ modules like ZooKeeper.  If you require such functionality, you need to add additional dependencies.