mirror of https://github.com/apache/lucene.git
SOLR-8299: ConfigSet DELETE operation no longer allows deletion of config sets that are currently in use by other collections
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1716223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23c73d8ff8
commit
d3401ccc66
|
@ -574,6 +574,9 @@ Other Changes
|
|||
|
||||
* SOLR-8277: (Search|Top)GroupsFieldCommand tweaks (Christine Poerschke)
|
||||
|
||||
* SOLR-8299: ConfigSet DELETE operation no longer allows deletion of config sets that
|
||||
are currently in use by other collections (Anshum Gupta)
|
||||
|
||||
================== 5.3.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -46,9 +46,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import static org.apache.solr.cloud.OverseerMessageHandler.ExclusiveMarking.NONEXCLUSIVE;
|
||||
import static org.apache.solr.cloud.OverseerMessageHandler.ExclusiveMarking.NOTDETERMINED;
|
||||
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
|
||||
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.DELETE;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
|
||||
|
||||
/**
|
||||
* A {@link OverseerMessageHandler} that handles ConfigSets API related
|
||||
|
@ -351,6 +350,12 @@ public class OverseerConfigSetMessageHandler implements OverseerMessageHandler {
|
|||
throw new SolrException(ErrorCode.BAD_REQUEST, "ConfigSet does not exist to delete: " + configSetName);
|
||||
}
|
||||
|
||||
for (String s : zkStateReader.getClusterState().getCollections()) {
|
||||
if (configSetName.equals(zkStateReader.readConfigName(s)))
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||
"Can not delete ConfigSet as it is currently being used by collection [" + s + "]");
|
||||
}
|
||||
|
||||
String propertyPath = ConfigSetProperties.DEFAULT_FILENAME;
|
||||
NamedList properties = getConfigSetProperties(getPropertyPath(configSetName, propertyPath));
|
||||
if (properties != null) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.apache.solr.cloud;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.junit.Test;
|
||||
|
||||
@LuceneTestCase.Slow
|
||||
public class ConfigSetsAPITest extends AbstractFullDistribZkTestBase {
|
||||
public ConfigSetsAPITest() {
|
||||
super();
|
||||
sliceCount = 1;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigSetDeleteWhenInUse() throws Exception {
|
||||
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
|
||||
create.setConfigName("conf1");
|
||||
create.setCollectionName("test_configset_delete");
|
||||
create.setNumShards(1);
|
||||
create.process(cloudClient);
|
||||
waitForCollection(cloudClient.getZkStateReader(), "test_configset_delete", 1);
|
||||
|
||||
ConfigSetAdminRequest.Delete deleteConfigRequest = new ConfigSetAdminRequest.Delete();
|
||||
deleteConfigRequest.setConfigSetName("conf1");
|
||||
try {
|
||||
deleteConfigRequest.process(cloudClient);
|
||||
fail("The config deletion should cause an exception as it's currently being used by a collection.");
|
||||
} catch (SolrException e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Clean up the collection
|
||||
CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete();
|
||||
deleteCollectionRequest.setCollectionName("test_configset_delete");
|
||||
deleteCollectionRequest.process(cloudClient);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue